question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ENH: sort=bool keyword argument for index.difference

See original GitHub issue

I often want to remove certain elements from an index while retaining the original ordering of the index. For this reason a sort keyword in the index.difference method would be required:

In: index = pd.Index([0, 1, 2, 4, 3])
In: index.difference({1, 2})
Out: Int64Index([0, 3, 4], dtype='int64')
# It would be cool to have instead
In: index.difference({1, 2}, sort=False)
Out: Int64Index([0, 4, 3], dtype='int64')

I think that this usecase appears frequently and setting the default to sort=True doesn’t affect existing code.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Giftlincommented, Oct 14, 2017

I am interested in submitting a pull request. Can I?

0reactions
Licht-Tcommented, Oct 15, 2017

If the sort option needed in union, how do we define the unsorted union order? idx1.join(idx2.difference(idx1))?

Read more comments on GitHub >

github_iconTop Results From Across the Web

sort_index() got an unexpected keyword argument 'by' - ...
Method sort_index sorts values by dataframe index. What you want to do is to sort values by some columns. In this case you...
Read more >
Mesmerize Documentation
Mesmerize is a platform for the annotation and analysis of neuronal calcium imaging data. It encompasses the entire.
Read more >
Page — PyMuPDF 1.21.1 documentation - Read the Docs
Class representing a document page. A page object is created by Document.load_page() or, equivalently, via indexing the document like doc[n] ...
Read more >
PyMuPDF Documentation
So PyMuPDF cannot coexist with packages named “fitz” in the same Python ... Method Document.insert_pdf() copies pages between different PDF ...
Read more >
The SMT-LIBv2 Language and Tools: A Tutorial
At the 2010 SMT workshop, 10 different provers competed to demonstrate capability and perfor- ... function with no arguments) named x of sort...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found