Reputation: 41
Data is inconsistent.
I've tried to filter DataFrame with
df.Timestamp.dt.hour
gives only hours,
df.Timestamp.dt.minute
gives only minutes.
I need to filter for example every last entry of hour so 1:58, 2:54, 3:36, 4:44, etc.
I just need more efficient way, not explanation :)
Upvotes: 0
Views: 1028
Reputation: 27869
I think this should work:
df.sort_values('Date').groupby([df['Date'].dt.date, df['Date'].dt.hour], as_index=False).last()
Upvotes: 1