Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

I currently have a pandas Series with dtype Timestamp, and I want to group it by date (and have many rows with different times in each group).

The seemingly obvious way of doing this would be something similar to

grouped = s.groupby(lambda x: x.date())

However, pandas' groupby groups Series by its index. How can I make it group by value instead?

1 Answer

0 votes
by (41.4k points)

Use this:

grouped = s.groupby(s)

Or:

grouped = s.groupby(lambda x: s[x])

Related questions

0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 31, 2019 in Data Science by sourav (17.6k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...