Skip to content
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

API: add ignore_index keyword to .sort_* & .drop_duplicates #30114

Closed
jreback opened this issue Dec 6, 2019 · 1 comment · Fixed by #30578
Closed

API: add ignore_index keyword to .sort_* & .drop_duplicates #30114

jreback opened this issue Dec 6, 2019 · 1 comment · Fixed by #30578
Assignees
Labels
API Design Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Dec 6, 2019

I see lots of code that goes like this

In [17]: df = pd.DataFrame({'A': [1, 2, 3]})                                                                                                                                        

In [18]: df                                                                                                                                                                         
Out[18]: 
   A
0  1
1  2
2  3

In [19]: df.sort_values('A', ascending=False)                                                                                                                                       
Out[19]: 
   A
2  3
1  2
0  1

In [20]: df.sort_values('A', ascending=False).reset_index(drop=True)                                                                                                                
Out[20]: 
   A
0  3
1  2
2  1

might be nice from an API / consistency perspective to add a ignore_index=False|True keyword to .sort_values(), and .drop_duplicates() that does the reset in-line; this would give consistency similar to a pd.concat([......], ignore_index=True) operation which users are very familiar

@jreback jreback added Reshaping Concat, Merge/Join, Stack/Unstack, Explode API Design labels Dec 6, 2019
@jreback jreback added this to the Contributions Welcome milestone Dec 6, 2019
@charlesdong1991
Copy link
Member

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants