You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/whatsnew/v0.20.0.txt
+18-17
Original file line number
Diff line number
Diff line change
@@ -466,12 +466,12 @@ list, and a dict of column names to scalars or lists. This provides a useful syn
466
466
(potentially different) aggregations.
467
467
468
468
However, ``.agg(..)`` can *also* accept a dict that allows 'renaming' of the result columns. This is a complicated and confusing syntax, as well as not consistent
469
-
between ``Series`` and ``DataFrame``. We are deprecating this 'renaming' functionarility.
469
+
between ``Series`` and ``DataFrame``. We are deprecating this 'renaming' functionaility.
470
470
471
471
1) We are deprecating passing a dict to a grouped/rolled/resampled ``Series``. This allowed
472
472
one to ``rename`` the resulting aggregation, but this had a completely different
473
473
meaning than passing a dictionary to a grouped ``DataFrame``, which accepts column-to-aggregations.
474
-
2) We are deprecating passing a dict-of-dict to a grouped/rolled/resampled ``DataFrame`` in a similar manner.
474
+
2) We are deprecating passing a dict-of-dicts to a grouped/rolled/resampled ``DataFrame`` in a similar manner.
475
475
476
476
This is an illustrative example:
477
477
@@ -488,17 +488,15 @@ columns and applying the list of functions. This returns a ``MultiIndex`` for th
488
488
489
489
.. ipython:: python
490
490
491
-
df.groupby('A').agg({'B': ['sum', 'max'],
492
-
'C': ['count', 'min']})
493
-
491
+
df.groupby('A').agg({'B': 'sum', 'C': 'min'})
494
492
495
493
Here's an example of the first deprecation (1), passing a dict to a grouped ``Series``. This
496
494
is a combination aggregation & renaming:
497
495
498
496
.. code-block:: ipython
499
497
500
498
In [6]: df.groupby('A').B.agg({'foo': 'count'})
501
-
FutureWarning: using a dictionary on a Series for aggregation
499
+
FutureWarning: using a dict on a Series for aggregation
502
500
is deprecated and will be removed in a future version
503
501
504
502
Out[6]:
@@ -518,24 +516,27 @@ Here's an example of the second deprecation (2), passing a dict-of-dict to a gro
518
516
519
517
.. code-block:: python
520
518
521
-
In [23]: df.groupby('A').agg({'B': {'foo': ['sum', 'max']}, 'C': {'bar': ['count', 'min']}})
522
-
FutureWarning: using a dictionary on a Series for aggregation
523
-
is deprecated and will be removed in a future version
519
+
In [23]: (df.groupby('A')
520
+
.agg({'B': {'foo': 'sum'}, 'C': {'bar': 'min'}})
521
+
)
522
+
FutureWarning: using a dict with renaming is deprecated and will be removed in a future version
524
523
525
524
Out[23]:
526
-
foo bar
527
-
sum max count min
525
+
BC
526
+
foo bar
528
527
A
529
-
1 3 2 3 0
530
-
2 7 4 2 3
528
+
1 3 0
529
+
2 7 3
531
530
532
-
You can accomplish the same by:
531
+
532
+
You can accomplish nearly the same by:
533
533
534
534
.. ipython:: python
535
535
536
-
r = df.groupby('A').agg({'B': ['sum', 'max'], 'C': ['count', 'min']})
0 commit comments