October 2017
Intermediate to advanced
532 pages
16h 10m
English
The read_csv function in step 1 allows to both convert columns into Timestamps and put them in the index at the same time creating a DatetimeIndex. Steps 2 does a simple groupby operation with a single grouping column, gender. Step 3 uses the resample method with the offset alias 10AS to form groups in 10-year increments of time. The A is the alias for year and the S informs us that the beginning of the period is used as the label. For instance, the data for the label 1988-01-01 spans that date until December 31, 1997.
Interestingly, the object returned from a call to the groupby method has its own resample method, but the reverse is not true:
>>> 'resample' in dir(employee.groupby('GENDER'))True>>> 'groupby' in dir(employee.resample('10AS')) ...Read now
Unlock full access