groupby in pandas by datetime object in python code example Example: groupby year datetime pandas data.groupby(data.date.dt.year)