Lerner Consulting Blogยท
Pandas groupby on datetime parts with the dt accessor
TL;DR
To summarize data by part of a datetime column in Pandas, use the dt accessor to extract the time component and group by it. This lets you calculate aggregates such as mean trip distance for each group without grouping by full timestamps.