From e1c5a881d12275ea55c90a46a6d2a4328de9bf0d Mon Sep 17 00:00:00 2001 From: weikhor Date: Thu, 17 Dec 2020 23:03:13 +0800 Subject: [PATCH] testing case sort_index with pd.set_option('use_inf_as_na', True) --- pandas/tests/frame/methods/test_sort_index.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pandas/tests/frame/methods/test_sort_index.py b/pandas/tests/frame/methods/test_sort_index.py index de847c12723b2..16eb9d2f52642 100644 --- a/pandas/tests/frame/methods/test_sort_index.py +++ b/pandas/tests/frame/methods/test_sort_index.py @@ -857,3 +857,23 @@ def test_sort_index_multiindex_sparse_column(self): result = expected.sort_index(level=0) tm.assert_frame_equal(result, expected) + + def test_sort_index_mode_true(self): + d = {'col1': [1, 2, 3], 'col2': [3, 4, 5]} + df = pd.DataFrame(data=d) + now = pd.Timestamp.now() + df.index = [now, now - pd.Timedelta('1m'), now + pd.Timedelta('2m')] + + try: + df1 = df.sort_index() + except Exception as ex: + print('test 1 failed: ', ex) + + pd.set_option('use_inf_as_na', True) + + try: + df2 = df.sort_index() + except Exception as ex: + print('test 2 failed: ', ex) + +