@@ -1816,13 +1816,14 @@ def _set_name(
1816
1816
Parrot 20.0
1817
1817
Name: Max Speed, dtype: float64
1818
1818
1819
- We can pass a list of values (Here: ["a", "b", "a", "b"]) to group the Series data by custom labels:
1819
+ We can pass a list of values (Here: ["a", "b", "a", "b"]) to
1820
+ group the Series data by custom labels:
1820
1821
>>> ser.groupby(["a", "b", "a", "b"]).mean()
1821
1822
a 210.0
1822
1823
b 185.0
1823
1824
Name: Max Speed, dtype: float64
1824
1825
1825
- Grouping by numeric labels yields similar results: (Here: [0, 1, 0, 1]):
1826
+ Grouping by numeric labels yields similar results (Here: [0, 1, 0, 1]):
1826
1827
>>> ser.groupby([0, 1, 0, 1]).mean()
1827
1828
0 210.0
1828
1829
1 185.0
@@ -1866,7 +1867,8 @@ def _set_name(
1866
1867
Parrot 25.0
1867
1868
Name: Max Speed, dtype: float64
1868
1869
1869
- We can also group by the 'Type' level of the hierarchical index to get the mean speed for each type:
1870
+ We can also group by the 'Type' level of the hierarchical index
1871
+ to get the mean speed for each type:
1870
1872
1871
1873
>>> ser.groupby(level="Type").mean()
1872
1874
Type
@@ -1890,7 +1892,9 @@ def _set_name(
1890
1892
NaN 3
1891
1893
dtype: int64
1892
1894
1893
- We can also group by a custom list (Here: ["a", "b", "a", np.nan]) with NaN values to handle missing group labels:
1895
+ We can also group by a custom list with NaN values to handle
1896
+ missing group labels (Here: ["a", "b", "a", np.nan]):
1897
+
1894
1898
>>> arrays = ['Falcon', 'Falcon', 'Parrot', 'Parrot']
1895
1899
>>> ser = pd.Series([390., 350., 30., 20.], index=arrays, name="Max Speed")
1896
1900
>>> ser.groupby(["a", "b", "a", np.nan]).mean()
0 commit comments