Skip to content

Instantly share code, notes, and snippets.

@axil
Created January 4, 2023 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axil/7519b0b863827a291a704a8e765e2a3e to your computer and use it in GitHub Desktop.
Save axil/7519b0b863827a291a704a8e765e2a3e to your computer and use it in GitHub Desktop.
groupby-sort
>>> s = pd.Series([1, 3, 20, 2, 10])
>>> for k, v in s.groupby(s//10, sort=False):
print(k, v.tolist())
0 [1, 3, 2]
2 [20]
1 [10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment