@@ -470,10 +470,9 @@ def _aggregate_named(self, func, *args, **kwargs):
470
470
471
471
__examples_series_doc = dedent (
472
472
"""
473
- >>> ser = pd.Series(
474
- ... [390.0, 350.0, 30.0, 20.0],
475
- ... index=["Falcon", "Falcon", "Parrot", "Parrot"],
476
- ... name="Max Speed")
473
+ >>> ser = pd.Series([390.0, 350.0, 30.0, 20.0],
474
+ ... index=["Falcon", "Falcon", "Parrot", "Parrot"],
475
+ ... name="Max Speed")
477
476
>>> grouped = ser.groupby([1, 1, 2, 2])
478
477
>>> grouped.transform(lambda x: (x - x.mean()) / x.std())
479
478
Falcon 0.707107
@@ -1331,14 +1330,10 @@ class DataFrameGroupBy(GroupBy[DataFrame]):
1331
1330
"""
1332
1331
Examples
1333
1332
--------
1334
- >>> df = pd.DataFrame(
1335
- ... {
1336
- ... "A": [1, 1, 2, 2],
1333
+ >>> data = {"A": [1, 1, 2, 2],
1337
1334
... "B": [1, 2, 3, 4],
1338
- ... "C": [0.362838, 0.227877, 1.267767, -0.562860],
1339
- ... }
1340
- ... )
1341
-
1335
+ ... "C": [0.362838, 0.227877, 1.267767, -0.562860]}
1336
+ >>> df = pd.DataFrame(data)
1342
1337
>>> df
1343
1338
A B C
1344
1339
0 1 1 0.362838
@@ -1393,7 +1388,8 @@ class DataFrameGroupBy(GroupBy[DataFrame]):
1393
1388
1394
1389
>>> df.groupby("A").agg(
1395
1390
... b_min=pd.NamedAgg(column="B", aggfunc="min"),
1396
- ... c_sum=pd.NamedAgg(column="C", aggfunc="sum"))
1391
+ ... c_sum=pd.NamedAgg(column="C", aggfunc="sum")
1392
+ ... )
1397
1393
b_min c_sum
1398
1394
A
1399
1395
1 1 0.590715
@@ -2154,7 +2150,7 @@ def idxmax(
2154
2150
2155
2151
>>> df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
2156
2152
... 'co2_emissions': [37.2, 19.66, 1712]},
2157
- ... index=['Pork', 'Wheat Products', 'Beef'])
2153
+ ... index=['Pork', 'Wheat Products', 'Beef'])
2158
2154
2159
2155
>>> df
2160
2156
consumption co2_emissions
@@ -2236,7 +2232,7 @@ def idxmin(
2236
2232
2237
2233
>>> df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48],
2238
2234
... 'co2_emissions': [37.2, 19.66, 1712]},
2239
- ... index=['Pork', 'Wheat Products', 'Beef'])
2235
+ ... index=['Pork', 'Wheat Products', 'Beef'])
2240
2236
2241
2237
>>> df
2242
2238
consumption co2_emissions
@@ -2319,9 +2315,9 @@ def value_counts(
2319
2315
Examples
2320
2316
--------
2321
2317
>>> df = pd.DataFrame({
2322
- ... 'gender': ['male', 'male', 'female', 'male', 'female', 'male'],
2323
- ... 'education': ['low', 'medium', 'high', 'low', 'high', 'low'],
2324
- ... 'country': ['US', 'FR', 'US', 'FR', 'FR', 'FR']
2318
+ ... 'gender': ['male', 'male', 'female', 'male', 'female', 'male'],
2319
+ ... 'education': ['low', 'medium', 'high', 'low', 'high', 'low'],
2320
+ ... 'country': ['US', 'FR', 'US', 'FR', 'FR', 'FR']
2325
2321
... })
2326
2322
2327
2323
>>> df
0 commit comments