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()
#!head Freemont.csv same as...
data.head()
Out[3]:
In [4]:
data.resample('W').sum().plot()
Out[4]:
In [5]:
# check for year trends by using rolling windows - sum in the previous 365 days
ax = data.resample('D').rolling(365).sum().plot()
ax.set_ylim(0, None)
Out[5]:
In [6]:
# are there any time patterns?
data.groupby(data.index.time).mean().plot()
Out[6]:
In [7]:
# see the same, but year-wise, using a pivot table
pivoted = data.pivot_table('Total', index=data.index.time, columns=data.index.date)
pivoted.iloc[:5, :5] #each column is a day, each row is a time
Out[7]:
In [8]:
pivoted.plot(legend=False) #we now have a line for each day
Out[8]:
In [9]:
pivoted.plot(legend=False, alpha=0.01) #better looking
#some days have a bimodal pattern, some have not -> weekdays vs weekends/holidays?
Out[9]:
In [11]:
#this prints the docs
get_fremont_data?
In [ ]:
#shift+tab will get params
get_fremont_data()