-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
Ensure Index._data is an ndarray #23628
Ensure Index._data is an ndarray #23628
Conversation
BUG: Ensure that Index._data is an ndarray Split from pandas-dev#23623, where it was causing issues with infer_dtype.
Hello @TomAugspurger! Thanks for submitting the PR.
|
lgtm. circle seems to be failing lots of PRs today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rather fix the places where _simple_new
is called with an Index or Series ? Or are that many places (I suppose the bool code path) ?
I started fixing the callers, but gave up when I saw all the potential call sites. It's not just boolean index, the numeric ones hit this as well. |
I didn't look into why the expected failures in |
Codecov Report
@@ Coverage Diff @@
## master #23628 +/- ##
=========================================
Coverage ? 92.24%
=========================================
Files ? 161
Lines ? 51341
Branches ? 0
=========================================
Hits ? 47362
Misses ? 3979
Partials ? 0
Continue to review full report at Codecov.
|
All green. |
+1 for the "sooner side of eventually" pile |
@jbrockmendel can you comment on the skips / expected values in It seems to me like the expected values are incorrect. Consider ops.rand_(series, index) -> Series but it seems to me that edit: just saw your reply. |
Based on my thinking in |
Any objections to merging? (this is blocking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comment
pandas/core/indexes/base.py
Outdated
@@ -522,6 +522,12 @@ def _simple_new(cls, values, name=None, dtype=None, **kwargs): | |||
values = cls(values, name=name, dtype=dtype, | |||
**kwargs)._ndarray_values | |||
|
|||
if isinstance(values, (ABCSeries, cls)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should use ABCIndexClass here? it’s acrually more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can never remember whether ABCIndexClass
or ABCIndex
includes subclasses, so I was happy when I realized I could just use cls
here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ABCIndexClass - it’s just more consistent in the code
@TomAugspurger just to be clear: regarding the behaviour of |
To be clear, I added a test for `roxr(Series, Index)`. And if we're using
the most sensible definition of
roxr(Series, Index) == xor(Index, Series)
then yes, the test should be correct. In that case the expected is
`Index([])`, since they both contained True and False.
…On Wed, Nov 14, 2018 at 4:34 AM Joris Van den Bossche < ***@***.***> wrote:
@TomAugspurger <https://github.com/TomAugspurger> just to be clear:
regarding the behaviour of xor with Index / Series, did you decide that
the current behaviour is correct? (as you added a test for it)?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#23628 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIut2wEt79DaAYgZzvn3fB731C6ykks5uu_GXgaJpZM4YYsIq>
.
|
pandas/tests/indexes/test_base.py
Outdated
@@ -504,6 +504,12 @@ def test_constructor_cast(self): | |||
with pytest.raises(ValueError, match=msg): | |||
Index(["a", "b", "c"], dtype=float) | |||
|
|||
def test_constructor_unwraps_index(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can make this more general by using the indices fixture here.
pandas/tests/indexes/test_numeric.py
Outdated
@@ -628,6 +628,12 @@ def test_constructor_coercion_signed_to_unsigned(self, uint_dtype): | |||
with pytest.raises(OverflowError, match=msg): | |||
Index([-1], dtype=uint_dtype) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than specificying testing a single index, see my above comment.
parametrized over |
All green. |
OK for the xor behaviour (We should maybe consider deprecating it, but that's a separate issue) |
@TomAugspurger Thanks! |
* upstream/master: BUG: to_html misses truncation indicators (...) when index=False (pandas-dev#22786) API/DEPR: replace "raise_conflict" with "errors" for df.update (pandas-dev#23657) BUG: Append DataFrame to Series with dateutil timezone (pandas-dev#23685) CLN/CI: Catch that stderr-warning! (pandas-dev#23706) ENH: Allow for join between two multi-index dataframe instances (pandas-dev#20356) Ensure Index._data is an ndarray (pandas-dev#23628) DOC: flake8-per-pr for windows users (pandas-dev#23707) DOC: Handle exceptions when computing contributors. (pandas-dev#23714) DOC: Validate space before colon docstring parameters pandas-dev#23483 (pandas-dev#23506) BUG-22984 Fix truncation of DataFrame representations (pandas-dev#22987)
Split from #23623, where it was
causing issues.