John
John

Reputation: 23

Averaging Python Pandas Date format

I have some data like the format below:

2016-06-02 22:00:00 
2016-06-02 22:00:01 
2016-06-02 22:00:01 
2016-06-02 22:00:02 
2016-06-02 22:00:02

This data is in a Pandas DataFrame, and what I want is to averagint it by days, like this:

2016-06-2  I 300 

So I would like to calculate how many items, was averaged by this.

Any ideas? I tried to use value_counts, but it gave a false result.

Upvotes: 1

Views: 47

Answers (1)

jezrael
jezrael

Reputation: 863511

It seems you need:

df = df['date'].dt.date.value_counts()

Or:

df = df.groupby(df['date'].dt.date).size()

Upvotes: 2

Related Questions