groupby function groups by in local context. It actually groups only things that belong to single group inside continuous group.

group by of this stroke:
[k for k, g in groupby('AAAABBBCCDAABBB')] --> A B C D A B

What I actually expected it to do:

[k for k, g in groupby('AAAABBBCCDAABBB')] --> A B C D

@deshipu meh, it becomes faster and easier to make the group by via dict by hands :/

@alexcleac "What I actually expected it to do:
A B C D"

for i in sorted(s): print(i, end=" ")


@alexcleac To be able to use Pandas' groupby you must have at least 2 groups of data. You have only one group in your example. :)

Sign in to participate in the conversation
Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either! We adhere to an adapted version of the TootCat Code of Conduct and have documented a list of blocked instances. Ash is the admin and is supported by Fuzzface, Brian!, and Daniel Glus as moderators. Hosting costs are largely covered by our generous supporters on Patreon – thanks for all the help!