@@ -330,15 +330,26 @@ def test_pct_max_many_rows(self):
330
330
result = df .rank (pct = True ).max ()
331
331
assert (result == 1 ).all ()
332
332
333
- def test_rank_minus_inf_keep_na (self ):
333
+ def test_rank_minus_inf_keep_nan (self ):
334
334
# GH 32593
335
335
expected_df = DataFrame ({'col' : np .array ([2.0 , 4.0 , np .nan , 3.0 , 1.0 ])})
336
336
result_df = DataFrame ({'col' : np .array ([1 , np .inf , np .nan , 10 , - np .inf ])}).rank (na_option = 'keep' )
337
337
tm .assert_frame_equal (expected_df , result_df )
338
338
339
- def test_rank_inf_keep_na (self ):
339
+ def test_rank_inf_keep_nan (self ):
340
+ # GH 32593
340
341
expected_df = DataFrame ({'col' : np .array ([1.0 , 2.0 , 3.0 ])})
341
342
result_df = DataFrame ({'col' : np .array ([- np .inf , 0 , np .inf ])}).rank (na_option = 'keep' )
342
343
tm .assert_frame_equal (expected_df , result_df )
343
344
344
-
345
+ def test_rank_inf_bottom_nan (self ):
346
+ # GH 32593
347
+ expected_df = DataFrame ({'col' : np .array ([1.0 , 2.0 , 4.0 , 3.0 ])})
348
+ result_df = DataFrame ({'col' : np .array ([- np .inf , 0 , np .nan , np .inf ])}).rank (na_option = 'bottom' )
349
+ tm .assert_frame_equal (expected_df , result_df )
350
+
351
+ def test_rank_inf_decimal_nan (self ):
352
+ # GH 32593
353
+ expected_df = DataFrame ({'col' : np .array ([2.0 ,3.0 ,4.5 ,6.0 ,1.0 ,4.5 ])})
354
+ result_df = DataFrame ({'col' : np .array ([5.5 , 6.99 , np .inf , np .nan , 0.7 , np .inf ])}).rank (na_option = 'bottom' )
355
+ tm .assert_frame_equal (expected_df , result_df )
0 commit comments