Format

L'idée est de tester l'ouput d'un notebook dans un "beau" document scientific. I.e.: données dans des tableaux, computation masquée.

Output en PDF

  • on peut créer un pdf à partir du notebook, voir README

Variables dans markdown

Formatter output en HTML


In [1]:
h = ['a', 'b', 'c', 'd']

In [12]:
table = '<table>'
for i in h:
    table += '<th>{}</th>'.format(i)
table += '</table>'
table


Out[12]:
'<table><th>a</th><th>b</th><th>c</th><th>d</th></table>'

In [7]:
import numpy as np
import pandas as pd

df = pd.DataFrame(np.arange(12.).reshape((3,4)))
df


Out[7]:
0 1 2 3
0 0 1 2 3
1 4 5 6 7
2 8 9 10 11

In [8]:
from IPython.display import display, HTML

display(df)


0 1 2 3
0 0 1 2 3
1 4 5 6 7
2 8 9 10 11

In [9]:
HTML(df.to_html())


Out[9]:
0 1 2 3
0 0 1 2 3
1 4 5 6 7
2 8 9 10 11

In [10]:
df.to_html()


Out[10]:
'<table border="1" class="dataframe">\n  <thead>\n    <tr style="text-align: right;">\n      <th></th>\n      <th>0</th>\n      <th>1</th>\n      <th>2</th>\n      <th>3</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>0</td>\n      <td>1</td>\n      <td>2</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>4</td>\n      <td>5</td>\n      <td>6</td>\n      <td>7</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>8</td>\n      <td>9</td>\n      <td>10</td>\n      <td>11</td>\n    </tr>\n  </tbody>\n</table>'

In [13]:
HTML(table)


Out[13]:
abcd