In [1]:
URL = 'https://data.seattle.gov/api/views/65db-xm6k/rows.csv?accessType=DOWNLOAD'
In [2]:
from urllib.request import urlretrieve
urlretrieve(URL, 'Fremont.csv')
Out[2]:
In [3]:
!head Fremont.csv
In [4]:
import pandas as pd
df = pd.read_csv('Fremont.csv', index_col='Date', parse_dates=True)
df.head()
Out[4]:
In [5]:
%matplotlib inline
In [6]:
df.info()
In [7]:
df.plot()
Out[7]:
In [8]:
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
df.columns = ['West', 'East']
df.resample('W').sum().plot();
In [14]:
df['Total'] = df['West'] + df['East']
ax = df.resample('D').sum().rolling(365).sum().plot();
ax.set_ylim(0, None);
In [15]:
#trend in individual days
df.groupby(df.index.time).mean().plot();
In [16]:
pivoted = df.pivot_table('Total', index=df.index.time, columns=df.index.date)
pivoted.iloc[:5, :5]
Out[16]:
In [19]:
#line for each days of the year
pivoted.plot(legend=False, alpha=0.01);
In [ ]: