Skip to content

testing case sort_index with pd.set_option('use_inf_as_na', True) #38542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions pandas/tests/frame/methods/test_sort_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use pytest.raises here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this specific bit doesn't raise so this is a general pointer)

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)