Skip to content

Instantly share code, notes, and snippets.

@nyggus
Created September 23, 2022 06:21
Show Gist options
  • Save nyggus/02e09ff39a0a2515192b0c14b99cea36 to your computer and use it in GitHub Desktop.
Save nyggus/02e09ff39a0a2515192b0c14b99cea36 to your computer and use it in GitHub Desktop.
>>> print(
... iris >>
... group_by('Species') >>
... head(n=5)
... )
groups: ['Species']
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa
5 7.0 3.2 4.7 1.4 versicolor
6 6.4 3.2 4.5 1.5 versicolor
7 6.9 3.1 4.9 1.5 versicolor
8 5.5 2.3 4.0 1.3 versicolor
9 6.5 2.8 4.6 1.5 versicolor
10 6.3 3.3 6.0 2.5 virginica
11 5.8 2.7 5.1 1.9 virginica
12 7.1 3.0 5.9 2.1 virginica
13 6.3 2.9 5.6 1.8 virginica
14 6.5 3.0 5.8 2.2 virginica
[15 rows x 5 columns]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment