'getting counts for each day in a dataframe

I am currently trying out sentiment analysis on a set of tweets and was wondering how to get counts for the number of tweets in a particular day. The problem for me is that each day is super granular, right down to the second of the tweet being sent. How would I get the counts of tweets for a whole day like the 25th of Jan 2016.enter image description here



Solution 1:[1]

Firstly, make sure your date is actually a datetime or similar object. If not, convert it using pandas.to_datetime() .

Then extract the date from each datetime:

df['date_only'] = df['date'].dt.date

And finally groupby:

result = df.groupby('date_only').agg({'tweet': 'count'})

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lpounng