how to group a column based on date python code example Example: groupby year datetime pandas data.groupby(data.date.dt.year)