Skip to content

Test that using a tuple or list for parameter ascending of sort_index is the same #43963

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

Merged
merged 3 commits into from
Oct 16, 2021

Conversation

fandreuz
Copy link
Contributor

@fandreuz fandreuz commented Oct 10, 2021

I could not find a suitable place to add a whatsnew entry, if there is one I will push another commit.

df.set_index(["class", "animal"], inplace=True)

sorted1 = df.sort_index(level=(0, 1), ascending=[True, False])
sorted2 = df.sort_index(level=(0, 1), ascending=(True, False))
Copy link
Member

Choose a reason for hiding this comment

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

Please define index directly without set_index and define expected explicitly. Also parametrize over list and tuple. Please call sorted1 or sorted2 result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@phofl Thank you, please let me know if I addressed all the changes you requested in my last commit.

@jreback jreback added Reshaping Concat, Merge/Join, Stack/Unstack, Explode Testing pandas testing functions or related to the test suite labels Oct 13, 2021
@jreback jreback added this to the 1.4 milestone Oct 13, 2021
@@ -785,6 +785,48 @@ def test_sort_index_use_inf_as_na(self):
result = expected.sort_index()
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize(
"ascending",
[(True, False)],
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add another parameterization as a list also

Copy link
Contributor Author

@fandreuz fandreuz Oct 14, 2021

Choose a reason for hiding this comment

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

@jreback Sure, please have a look at fcb9850

@jreback jreback merged commit ecee969 into pandas-dev:master Oct 16, 2021
@jreback
Copy link
Contributor

jreback commented Oct 16, 2021

thanks @fAndreuzzi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reshaping Concat, Merge/Join, Stack/Unstack, Explode Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: sort_index method ignores ascending parameter of type tuple
3 participants