Skip to content

BUG: make Index.where behavior mirror Index.putmask behavior #39412

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 10 commits into from
Feb 3, 2021

Conversation

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them
  • whatsnew entry

# coerces to object
return self.astype(object).putmask(mask, value)
dtype = self._find_common_type_compat(value)
return self.astype(dtype).putmask(mask, value)
Copy link
Contributor

Choose a reason for hiding this comment

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

copy=False?

Copy link
Member Author

Choose a reason for hiding this comment

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

we'll always be making a copy here since dtype != self.dtype

@@ -799,29 +799,22 @@ def length(self):
return Index(self._data.length, copy=False)

def putmask(self, mask, value):
arr = self._data.copy()
mask = np.asarray(mask, dtype=bool)
Copy link
Contributor

Choose a reason for hiding this comment

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

can't you share / use the array/interval putmask code here?

Copy link
Member Author

Choose a reason for hiding this comment

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

we do; L814-815 is directly using IntervalArray.putmask. everything before that point is for ways that the Index method behaves differently from the array method

@jreback jreback added Dtype Conversions Unexpected or buggy dtype conversions Index Related to the Index class or subclasses labels Jan 28, 2021
@jreback
Copy link
Contributor

jreback commented Jan 28, 2021

needs a rebase. can you add a whatsnew on what is changing here

@jreback
Copy link
Contributor

jreback commented Jan 28, 2021

one more rebase

@jbrockmendel
Copy link
Member Author

rebased + green

@jreback
Copy link
Contributor

jreback commented Feb 2, 2021

can you merge master

@jbrockmendel
Copy link
Member Author

rebased + finally green

@jreback jreback added this to the 1.3 milestone Feb 3, 2021
@jreback jreback merged commit 6b8cc98 into pandas-dev:master Feb 3, 2021
@jbrockmendel jbrockmendel deleted the ref-index-methods branch February 3, 2021 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Index Related to the Index class or subclasses
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants