Skip to content

CLN: union_indexes #58183

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 4 commits into from
Apr 11, 2024
Merged

CLN: union_indexes #58183

merged 4 commits into from
Apr 11, 2024

Conversation

mroeschke
Copy link
Member

  • Just used sets where appropriate
  • Added some typing
  • Split some helper functions to branches where they are used

@mroeschke mroeschke added Clean Index Related to the Index class or subclasses labels Apr 8, 2024
@mroeschke mroeschke requested a review from WillAyd as a code owner April 8, 2024 18:57
@mroeschke mroeschke added this to the 3.0 milestone Apr 8, 2024

if list in kinds:
if len(kinds) > 1:
indexes = [
Index(list(x)) if not isinstance(x, Index) else x for x in indexes
]
kinds.remove(list)
kinds -= {list}
Copy link
Member

Choose a reason for hiding this comment

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

id expect this to be slightly slower?

Copy link
Member Author

Choose a reason for hiding this comment

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

In [2]: kinds = {pd.DatetimeIndex, pd.Index, list}

In [3]: %time kinds -= {list}
CPU times: user 3 µs, sys: 0 ns, total: 3 µs
Wall time: 4.29 µs

In [4]: kinds = list({pd.DatetimeIndex, pd.Index, list})

In [5]: %time kinds.remove(list)
CPU times: user 5 µs, sys: 1e+03 ns, total: 6 µs
Wall time: 8.82 µs

@mroeschke mroeschke merged commit bbefde5 into pandas-dev:main Apr 11, 2024
46 checks passed
@mroeschke mroeschke deleted the ref/union_indexes branch April 11, 2024 15:39
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
* Clean up logic in union_indexes

* add typing

* Just use the generator version

* Undo typing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants