@@ -1816,7 +1816,6 @@ def _set_name(
1816
1816
Parrot 20.0
1817
1817
Name: Max Speed, dtype: float64
1818
1818
1819
- We can pass a of values to group the `Series` data by custom labels:
1820
1819
1821
1820
>>> ser.groupby(["a", "b", "a", "b"]).mean()
1822
1821
a 210.0
@@ -1837,8 +1836,6 @@ def _set_name(
1837
1836
Parrot 25.0
1838
1837
Name: Max Speed, dtype: float64
1839
1838
1840
- We can group by a condition applied to the `Series` values:
1841
-
1842
1839
>>> ser.groupby(ser > 100).mean()
1843
1840
Max Speed
1844
1841
False 25.0
@@ -1868,9 +1865,6 @@ def _set_name(
1868
1865
Parrot 25.0
1869
1866
Name: Max Speed, dtype: float64
1870
1867
1871
- We can also group by the `Type` level of the hierarchical index
1872
- to get the mean speed for each type:
1873
-
1874
1868
>>> ser.groupby(level="Type").mean()
1875
1869
Type
1876
1870
Captive 210.0
@@ -1886,17 +1880,12 @@ def _set_name(
1886
1880
b 3
1887
1881
dtype: int64
1888
1882
1889
- To include `NA` values in the group keys, set `dropna=False`:
1890
-
1891
1883
>>> ser.groupby(level=0, dropna=False).sum()
1892
1884
a 3
1893
1885
b 3
1894
1886
NaN 3
1895
1887
dtype: int64
1896
1888
1897
- We can also group by a custom with `NaN` values to handle
1898
- missing group labels:
1899
-
1900
1889
>>> arrays = ['Falcon', 'Falcon', 'Parrot', 'Parrot']
1901
1890
>>> ser = pd.Series([390., 350., 30., 20.], index=arrays, name="Max Speed")
1902
1891
>>> ser.groupby(["a", "b", "a", np.nan]).mean()
0 commit comments