-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
TST/BUG (string dtype): Fix and adjust indexes string tests #59544
Conversation
pandas/tests/indexes/test_base.py
Outdated
if using_infer_string and HAS_PYARROW: | ||
tm.assert_extension_array_equal( | ||
new_index.values, pd.array(arr, dtype="str") | ||
) |
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.
This one I don't understand. Why is index.values
a numpy array in case of "python" storage?
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.
Yeah I thought I rolled that one back, the change was just something I tried.
Updated now
pandas/tests/indexes/test_base.py
Outdated
elif index.dtype == "str" and not index.dtype.storage == "python": | ||
with pytest.raises(NotImplementedError, match="i8"): | ||
index.view("i8") |
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.
This is just testing a different error, right? (just to understand why this has a separate branch)
(ideally we should also make it a TypeError, I assume, maybe can add a TODO note)
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.
added a TODO
# non-EA dtype indexes have special casting logic, so we punt here | ||
pass | ||
if isinstance(data, (set, frozenset)): | ||
data = list(data) |
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.
This is related to what you mentioned on slack, I assume?
idx = pd.Index({1, 2}, dtype="Int64")
idx = pd.Index({1, 2}, dtype="int64")
Whether we consider a set
as sequence as valid input for constructors or not (IMO it would also be fine to not do that more generally)
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.
Yes, correct. It#s explicitly allowed for Index, so we shouldn't break this now
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 see, for Series(..)
we disallow it explicitly, but for Index(..)
it currently works for non-EA dtypes. Sounds good to allow that for now.
Ah, still some mypy errors .. |
Thanks @phofl |
…ev#59544) Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
…ev#59544) Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
xref #54792