@@ -497,6 +497,28 @@ index are the group names and whose values are the sizes of each group.
497
497
498
498
``nth `` can act as a reducer *or * a filter, see :ref: `here <groupby.nth >`
499
499
500
+ Decimal columns are "nuisance" columns that .agg automatically excludes in groupby.
501
+
502
+ If you do wish to aggregate them you must do so explicitly:
503
+
504
+ .. ipython :: python
505
+
506
+ from decimal import Decimal
507
+ dec = pd.DataFrame(
508
+ {' name' : [' foo' , ' bar' , ' foo' , ' bar' ],
509
+ ' title' : [' boo' , ' far' , ' boo' , ' far' ],
510
+ ' id' : [123 , 456 , 123 , 456 ],
511
+ ' int_column' : [1 , 2 , 3 , 4 ],
512
+ ' dec_column1' : [Decimal(' 0.50' ), Decimal(' 0.15' ), Decimal(' 0.25' ), Decimal(' 0.40' )],
513
+ ' dec_column2' : [Decimal(' 0.20' ), Decimal(' 0.30' ), Decimal(' 0.55' ), Decimal(' 0.60' )]
514
+ },
515
+ columns = [' name' ,' title' ,' id' ,' int_column' ,' dec_column1' ,' dec_column2' ]
516
+ )
517
+
518
+ dec.groupby([' name' , ' title' , ' id' ], as_index = False ).sum()
519
+
520
+ dec.groupby([' name' , ' title' , ' id' ], as_index = False ).agg({' dec_column1' : ' sum' , ' dec_column2' : ' sum' })
521
+
500
522
.. _groupby.aggregate.multifunc :
501
523
502
524
Applying multiple functions at once
0 commit comments