@@ -1345,22 +1345,28 @@ def test_groupby_transform_with_int(self):
13451345 df = DataFrame (dict (A = [1 , 1 , 1 , 2 , 2 , 2 ], B = Series (1 , dtype = 'float64' ),
13461346 C = Series (
13471347 [1 , 2 , 3 , 1 , 2 , 3 ], dtype = 'float64' ), D = 'foo' ))
1348- result = df .groupby ('A' ).transform (lambda x : (x - x .mean ()) / x .std ())
1348+ with np .errstate (all = 'ignore' ):
1349+ result = df .groupby ('A' ).transform (
1350+ lambda x : (x - x .mean ()) / x .std ())
13491351 expected = DataFrame (dict (B = np .nan , C = Series (
13501352 [- 1 , 0 , 1 , - 1 , 0 , 1 ], dtype = 'float64' )))
13511353 assert_frame_equal (result , expected )
13521354
13531355 # int case
13541356 df = DataFrame (dict (A = [1 , 1 , 1 , 2 , 2 , 2 ], B = 1 ,
13551357 C = [1 , 2 , 3 , 1 , 2 , 3 ], D = 'foo' ))
1356- result = df .groupby ('A' ).transform (lambda x : (x - x .mean ()) / x .std ())
1358+ with np .errstate (all = 'ignore' ):
1359+ result = df .groupby ('A' ).transform (
1360+ lambda x : (x - x .mean ()) / x .std ())
13571361 expected = DataFrame (dict (B = np .nan , C = [- 1 , 0 , 1 , - 1 , 0 , 1 ]))
13581362 assert_frame_equal (result , expected )
13591363
13601364 # int that needs float conversion
13611365 s = Series ([2 , 3 , 4 , 10 , 5 , - 1 ])
13621366 df = DataFrame (dict (A = [1 , 1 , 1 , 2 , 2 , 2 ], B = 1 , C = s , D = 'foo' ))
1363- result = df .groupby ('A' ).transform (lambda x : (x - x .mean ()) / x .std ())
1367+ with np .errstate (all = 'ignore' ):
1368+ result = df .groupby ('A' ).transform (
1369+ lambda x : (x - x .mean ()) / x .std ())
13641370
13651371 s1 = s .iloc [0 :3 ]
13661372 s1 = (s1 - s1 .mean ()) / s1 .std ()
@@ -6179,7 +6185,7 @@ def test__cython_agg_general(self):
61796185
61806186 def test_cython_agg_empty_buckets (self ):
61816187 ops = [('mean' , np .mean ),
6182- ('median' , np .median ),
6188+ ('median' , lambda x : np .median ( x ) if len ( x ) > 0 else np . nan ),
61836189 ('var' , lambda x : np .var (x , ddof = 1 )),
61846190 ('add' , lambda x : np .sum (x ) if len (x ) > 0 else np .nan ),
61856191 ('prod' , np .prod ),
0 commit comments