The Denver crime dataset has all crime and traffic accidents together in one table, and separates them through the binary columns, IS_CRIME and IS_TRAFFIC. The resample method allows you to group by a period of time and aggregate specific columns separately.
Aggregating weekly crime and traffic accidents separately
Getting ready
In this recipe, we will use the resample method to group by each quarter of the year and then sum up the number of crimes and traffic accidents separately.
How to do it...
- Read in the crime hdf5 dataset, set the index as REPORTED_DATE, and then...