Skip to content

Commit 8f95910

Browse files
committed
Add test cases
1 parent d449a91 commit 8f95910

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

pandas/tests/frame/methods/test_rank.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,26 @@ def test_pct_max_many_rows(self):
330330
result = df.rank(pct=True).max()
331331
assert (result == 1).all()
332332

333-
def test_rank_minus_inf_keep_na(self):
333+
def test_rank_minus_inf_keep_nan(self):
334334
# GH 32593
335335
expected_df = DataFrame({'col': np.array([2.0, 4.0, np.nan, 3.0, 1.0])})
336336
result_df = DataFrame({'col': np.array([1, np.inf, np.nan, 10, -np.inf])}).rank(na_option='keep')
337337
tm.assert_frame_equal(expected_df, result_df)
338338

339-
def test_rank_inf_keep_na(self):
339+
def test_rank_inf_keep_nan(self):
340+
# GH 32593
340341
expected_df = DataFrame({'col': np.array([1.0, 2.0, 3.0])})
341342
result_df = DataFrame({'col': np.array([-np.inf, 0, np.inf])}).rank(na_option='keep')
342343
tm.assert_frame_equal(expected_df, result_df)
343344

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

Comments
 (0)