First Jupyter Notebook Post

This is a blog post created in Jupyter notebook.

The goal is to see how well this feature works. I'd like to be able to post Python code to my blog. Happily, Nikola supports that seamlessly.

Normally Nikola preserves the width of each notebook cell. It makes sense that it does this but that doesn't work so well with this template because of the navigation bar on the left side of the screen. That's OK, I can override it by changing the notebook styling with this if I need to:

#notebook-container {
  width: 800px;
}

And here is some Python code:

In [1]:
def square(x):
    return x**2

for i in range(10):
    print(square(i))
0
1
4
9
16
25
36
49
64
81

And a plot:

In [2]:
%matplotlib inline
import matplotlib

import pandas as pd
import pandas.util.testing as pd_testing
In [3]:
df = pd_testing.makeTimeDataFrame(20)
df.index = pd.date_range(start=pd.Timestamp.now().floor('D'), periods=df.shape[0])

df.plot(figsize=(10, 5))
Out[3]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f57609a2fd0>
four random colored lines ranging from -2 to 2 on the y axis and 20 days on the x axis

Magnificent!

Comments