pandas group dataframe based on date range code example Example: groupby year datetime pandas data.groupby(data.date.dt.year)