I have a python dataframe (df1
) which has a column time. I converted the column into a datetime series using pd.to_datetime(df1['time'])
. Now I get a column like this:
2016-08-24 00:00:00 2016-08-13 00:00:00
2016-08-24 00:00:00 2016-08-13 00:00:00
2016-08-24 00:00:00 2016-08-13 00:00:00
2016-08-24 00:00:00 2016-08-13 00:00:00
2016-08-24 00:00:01 2016-08-13 00:00:01
2016-08-24 00:00:01 2016-08-13 00:00:01
2016-08-24 00:00:02 2016-08-13 00:00:02
2016-08-24 00:00:02 2016-08-13 00:00:02
2016-08-24 00:00:02 2016-08-13 00:00:02
2016-08-24 00:00:02 2016-08-13 00:00:02
2016-08-24 00:00:02 2016-08-13 00:00:02
2016-08-24 00:00:02 2016-08-13 00:00:02
2016-08-24 00:00:02 2016-08-13 00:00:02
2016-08-24 00:00:02 2016-08-13 00:00:02
2016-08-24 00:00:02 2016-08-13 00:00:02
....
2016-08-24 23:59:59 2016-08-13 00:00:02
Essentially, I want the first column to be grouped by the hour, so that I can see how many entries are there in 1 hour. Any help will be great.
Using @jezrael setup.
df.resample(rule='H', how='count').rename(columns = {'time':'count'})
count
2016-08-24 00:00:00 1
2016-08-24 01:00:00 3
2016-08-24 02:00:00 1
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments