Skip to content

BUG: Fix difference functionality for Period Indexes #59148

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

Closed

Conversation

TiffL
Copy link

@TiffL TiffL commented Jun 29, 2024

@TiffL TiffL marked this pull request as draft June 29, 2024 21:00
@TiffL TiffL marked this pull request as ready for review June 30, 2024 00:27
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

lgtm @mroeschke @jbrockmendel any concerns?

def _difference(self, other, sort=None) -> PeriodIndex:
if isinstance(other, Index) and other.inferred_type == "string":
try:
other = other.astype(self.dtype)
Copy link
Member

Choose a reason for hiding this comment

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

I don’t think we do this type of casting in general. In fact, I’d expect the private _difference to only be reached with matching dtypes

tm.assert_index_equal(idx_diff, expected)

idx_diff = other.difference(index, sort)
expected = pd.Index([])
Copy link
Member

Choose a reason for hiding this comment

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

No, the difference should be the entire ‘other’

@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Index.difference is returning too many values
4 participants