A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/30114 below:

add ignore_index keyword to .sort_* & .drop_duplicates · Issue #30114 · pandas-dev/pandas · GitHub

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4