10000 BUG: allow empty multiindex (fixes .isin regression, GH16777) by drudd · Pull Request #16782 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

BUG: allow empty multiindex (fixes .isin regression, GH16777) #16782

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 11 commits into from
Jul 7, 2017
Prev Previous commit
Next Next commit
Use names property rather than _names in MultiIndex.isin
  • Loading branch information
Douglas Rudd authored and jreback committed Jul 7, 2017
commit c84f0bc1e5a1cda712b4f91045d761c6e92a8975
2 changes: 1 addition & 1 deletion pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2624,7 +2624,7 @@ def _wrap_joined_index(self, joined, other):
def isin(self, values, level=None):
if level is None:
values = MultiIndex.from_tuples(values,
Copy link
Contributor

Choose a reason for hiding this comment

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

you might be able to change this to _ensure_index(values) I think (as its more idiomatic). I also don't think you will need the .values

Copy link
Member

Choose a reason for hiding this comment

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

_ensure_index is not meant to support values for a MultiIndex I think:

In [159]: pd.core.indexes.base._ensure_index([(1, 2), (3, 4)])
Out[159]: Index([(1, 2), (3, 4)], dtype='object')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not able to address this before 0.20.3

names=self._names).values
names=self.names).values
return algos.isin(self.values, values)
else:
num = self._get_level_number(level)
Expand Down
0