0

I need to group the columns according to the date.

enter image description here

starttime   Dates   COUNT
0   2019-09-01 00:00:01.9580    2019-09-01  0
1   2019-09-01 00:00:04.1430    2019-09-01  0
2   2019-09-01 00:00:07.3090    2019-09-01  0
3   2019-09-01 00:00:08.0640    2019-09-01  0
4   2019-09-01 00:00:12.8510    2019-09-01  0
... ... ... ...
195 2019-09-01 00:08:17.9740    2019-09-01  0
196 2019-09-01 00:08:23.9270    2019-09-01  0
197 2019-09-01 00:08:25.5040    2019-09-01  0
198 2019-09-01 00:08:26.2810    2019-09-01  0
199 2019-09-01 00:08:27.3220    2019-09-01  0

I have used the below to split my 'starttime' column to just the Date and Time. I want to count the number of occurences of each date in 'COUNT column.

df['Dates'] = pd.to_datetime(df['starttime']).dt.date
df['Time'] = pd.to_datetime(df['starttime']).dt.time

For example

Date       COUNT
2019-09-01    25
2019-09-02    34

How can i do this?

1
  • Pls provide your sample dataframe data, not image screenshot Commented Nov 23, 2021 at 4:46

1 Answer 1

1

Try this :

output = df.Dates.value_counts().reset_index()
output.columns = ["Date", "Count"]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.