
Want to change the granularity when grouping on a Python Pandas data frame’s datetime column?
Use Grouper.
For example: Here we get the mean trip_distance per 14-day period:
df.groupby(pd.Grouper(key='tpep_pickup_datetime', freq='14D'))['trip_distance'].mean()
