@@ -1345,22 +1345,28 @@ def test_groupby_transform_with_int(self):
1345
1345
df = DataFrame (dict (A = [1 , 1 , 1 , 2 , 2 , 2 ], B = Series (1 , dtype = 'float64' ),
1346
1346
C = Series (
1347
1347
[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 ())
1349
1351
expected = DataFrame (dict (B = np .nan , C = Series (
1350
1352
[- 1 , 0 , 1 , - 1 , 0 , 1 ], dtype = 'float64' )))
1351
1353
assert_frame_equal (result , expected )
1352
1354
1353
1355
# int case
1354
1356
df = DataFrame (dict (A = [1 , 1 , 1 , 2 , 2 , 2 ], B = 1 ,
1355
1357
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 ())
1357
1361
expected = DataFrame (dict (B = np .nan , C = [- 1 , 0 , 1 , - 1 , 0 , 1 ]))
1358
1362
assert_frame_equal (result , expected )
1359
1363
1360
1364
# int that needs float conversion
1361
1365
s = Series ([2 , 3 , 4 , 10 , 5 , - 1 ])
1362
1366
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 ())
1364
1370
1365
1371
s1 = s .iloc [0 :3 ]
1366
1372
s1 = (s1 - s1 .mean ()) / s1 .std ()
@@ -6179,7 +6185,7 @@ def test__cython_agg_general(self):
6179
6185
6180
6186
def test_cython_agg_empty_buckets (self ):
6181
6187
ops = [('mean' , np .mean ),
6182
- ('median' , np .median ),
6188
+ ('median' , lambda x : np .median ( x ) if len ( x ) > 0 else np . nan ),
6183
6189
('var' , lambda x : np .var (x , ddof = 1 )),
6184
6190
('add' , lambda x : np .sum (x ) if len (x ) > 0 else np .nan ),
6185
6191
('prod' , np .prod ),
0 commit comments