@@ -533,26 +533,11 @@ def f():
533
533
self .frame .transform (['max' , 'sqrt' ])
534
534
self .assertRaises (ValueError , f )
535
535
536
- def test_agg_todo (self ):
537
- # if we have a transforming function & a reducer
538
- # we have to resolve
539
- # TODO
540
- # result = self.frame.apply([np.sqrt, np.mean])
541
-
542
- # TODO
543
- # difference in apply / agg semantics when passing a
544
- # row-wise aggregator
545
- pass
546
-
547
- def test_broken (self ):
548
- # TODO
549
- # df = pd.DataFrame({'A': range(5), 'B': 5})
550
- # result = df.agg({'A':['abs', 'sum'], 'B':['mean','max']})
551
- # expected = DataFrame({'A': [0, 4], 'B': [5, 5]},
552
- # columns=['A', 'B'],
553
- # index=['min', 'max'])
554
- # tm.assert_frame_equal(result, expected)
555
- pass
536
+ df = pd .DataFrame ({'A' : range (5 ), 'B' : 5 })
537
+
538
+ def f ():
539
+ with np .errstate (all = 'ignore' ):
540
+ df .agg ({'A' : ['abs' , 'sum' ], 'B' : ['mean' , 'max' ]})
556
541
557
542
def test_demo (self ):
558
543
# demonstration tests
@@ -604,3 +589,31 @@ def test_agg_reduce(self):
604
589
self .frame .B .max ()],
605
590
index = ['sum' , 'max' ])})
606
591
assert_frame_equal (result .reindex_like (expected ), expected )
592
+
593
+ def test_nuiscance_columns (self ):
594
+
595
+ # GH 15015
596
+ df = DataFrame ({'A' : [1 , 2 , 3 ],
597
+ 'B' : [1. , 2. , 3. ],
598
+ 'C' : ['foo' , 'bar' , 'baz' ],
599
+ 'D' : pd .date_range ('20130101' , periods = 3 )})
600
+
601
+ result = df .agg ('min' )
602
+ expected = Series ([1 , 1. , 'bar' , pd .Timestamp ('20130101' )],
603
+ index = df .columns )
604
+ assert_series_equal (result , expected )
605
+
606
+ result = df .agg (['min' ])
607
+ expected = DataFrame ([[1 , 1. , 'bar' , pd .Timestamp ('20130101' )]],
608
+ index = ['min' ], columns = df .columns )
609
+ assert_frame_equal (result , expected )
610
+
611
+ result = df .agg ('sum' )
612
+ expected = Series ([6 , 6. , 'foobarbaz' ],
613
+ index = ['A' , 'B' , 'C' ])
614
+ assert_series_equal (result , expected )
615
+
616
+ result = df .agg (['sum' ])
617
+ expected = DataFrame ([[6 , 6. , 'foobarbaz' ]],
618
+ index = ['sum' ], columns = ['A' , 'B' , 'C' ])
619
+ assert_frame_equal (result , expected )
0 commit comments