Jupyter Data Science Workflow

From exploratory analysis to reproducible science


In [1]:
%matplotlib inline
import matplotlib.pyplot as plt

plt.style.use("seaborn")

In [2]:
from jupyterworkflow.data import get_fremont_data

In [3]:
data = get_fremont_data()

In [4]:
data.head()


Out[4]:
West East Total
Date
2012-10-03 12:00:00 4.0 9.0 13.0
2012-10-03 01:00:00 4.0 6.0 10.0
2012-10-03 02:00:00 1.0 1.0 2.0
2012-10-03 03:00:00 2.0 3.0 5.0
2012-10-03 04:00:00 6.0 1.0 7.0

In [5]:
data.resample("W").sum().plot()


Out[5]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f39abf476d8>

In [6]:
data.resample("W").sum().plot()


Out[6]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f39ac8e0a20>

In [7]:
ax = data.resample("D").sum().rolling(365).sum().plot()
ax.set_ylim(0, None)


Out[7]:
(0, 1058559.2)

In [8]:
data.groupby(data.index.time).mean().plot()


Out[8]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f39a91eb828>

In [9]:
pivoted = data.pivot_table("Total", index=data.index.time, columns=data.index.date)
pivoted.iloc[:5, :5]


Out[9]:
2012-10-03 2012-10-04 2012-10-05 2012-10-06 2012-10-07
01:00:00 50.0 64.5 60.0 96.0 122.5
02:00:00 65.0 64.0 66.0 106.0 122.0
03:00:00 84.5 75.0 84.0 107.0 118.5
04:00:00 161.0 141.5 159.5 94.0 114.0
05:00:00 307.0 266.5 229.5 92.5 100.0

In [10]:
pivoted.plot(legend=False, alpha=0.01)


Out[10]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f39a8bd4cc0>

In [11]:
get_fremont_data??