I have a dataframe df with column time as a string.
I want to get a count of these entries grouped hourly.
for example how many time entries are there between every hour from 00:00:00 to 23:59:59.
CodePudding user response:
You can group by the hour of this column using something like this:
df.groupby(df.Time.dt.hour).count()
CodePudding user response:
As you have a string, you can slice the hour part and value_counts
:
out = df['Time'].str[:2].value_counts(sort=False)
Or:
out = df.groupby(df['Time'].str[:2]).count()