October 2017
Intermediate to advanced
532 pages
16h 10m
English
It is possible to use resample even when the index does not contain a Timestamp. You can use the on parameter to select the column with Timestamps that will be used to form groups:
>>> crime = pd.read_hdf('data/crime.h5', 'crime')>>> weekly_crimes2 = crime.resample('W', on='REPORTED_DATE').size()>>> weekly_crimes2.equals(weekly_crimes)True
Similarly, this is possible using groupby with pd.Grouper by selecting the Timestamp column with the key parameter:
>>> weekly_crimes_gby2 = crime.groupby(pd.Grouper(key='REPORTED_DATE', freq='W')).size()>>> weekly_crimes_gby2.equals(weekly_crimes_gby)True
We can also easily produce a line plot of all the crimes in Denver (including traffic accidents) by calling the plot method on our ...
Read now
Unlock full access