-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH: Add ignore_index to sort_index #30578
ENH: Add ignore_index to sort_index #30578
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @charlesdong1991 for the PR.
sr = Series(original_list) | ||
expected = Series(sorted_list, index=output_index) | ||
|
||
# Test when inplace is False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can inplace be parameterised easily
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emm, i think in this case, if using parameterization, might not look very clean and less readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be parametrized - what do you think makes it less readable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok with trying parameterize as a followup, as for .sort_values and .duplicated these tests look very much like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emm, okay! i thought with inplace
being Ture
, we do not need to do something like df = df.sort_index(inplace=True)
, but False
needs to be like this, and testing object will be different, one is testing if original changes, another is to test if assigned new df is changed.
Sorry to bring up discussion here, it definitely can be parametrized, was just my preference on such case. I will parametrize all three methods in the follow-up PR for sure!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks generally good - a few comments
({"A": [1, 2, 3]}, {"A": [3, 2, 1]}, False, True, [0, 1, 2]), | ||
({"A": [1, 2, 3]}, {"A": [1, 2, 3]}, True, True, [0, 1, 2]), | ||
({"A": [1, 2, 3]}, {"A": [3, 2, 1]}, False, False, [2, 1, 0]), | ||
({"A": [1, 2, 3]}, {"A": [1, 2, 3]}, True, False, [0, 1, 2]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor but can you use a non-default index as part of the expectation? Right now the parametrization can't disambiguate between the default index and ignore_index
argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! changed!
sr = Series(original_list) | ||
expected = Series(sorted_list, index=output_index) | ||
|
||
# Test when inplace is False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be parametrized - what do you think makes it less readable?
sr = Series(original_list) | ||
expected = Series(sorted_list, index=output_index) | ||
|
||
# Test when inplace is False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok with trying parameterize as a followup, as for .sort_values and .duplicated these tests look very much like this.
Lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. if you can followup with a parameterization / deduplication of tests PR would be great
thanks! will do @jreback |
Hi, |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
@jreback
I just looked back at #30114 and found out that i overlooked to add
ignore_index
tosort_index
, and this might be the reason this issue is still left open. I added this tosort_index
to close this issue.