-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ERR: _shallow_copy should assert dtype #13294
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
Comments
An example for the same issue: i = pd.Index([0, 'A'])
i._shallow_copy(['A', np.nan])
Out[7]: Index(['A', 'nan'], dtype='<U3') The output should be as follows pd.Index(['A', np.nan])
Out[8]: Index(['A', nan], dtype='object') And another issue in dti = pd.DatetimeIndex([0])
dti._shallow_copy([pd.Timestamp(0)])
Out[12]: array(['1970-01-01T00:00:00.000000000'], dtype='datetime64[ns]') The expected output is as in the following: dti._shallow_copy([0])
Out[13]: DatetimeIndex(['1970-01-01'], dtype='datetime64[ns]', freq=None)
|
these violate guarantees of _shallow_copy the data must already be an index |
This is probably something I misunderstood (misunderstand) about Does it mean that all those examples (including And the only valid
is an index or an np.array with dtype compatible with idx.dtype (and not just a plain list)? |
yep - this issue is about a) making sure that we are an Index (or values is an ndarray) or raise |
Thanks! |
A lot of thought has gone into related topics for PeriodArray etc. I think the conclusion is pretty much that the caller is responsible for checking the inputs, since shallowxopy is private. Assertions in simplenew might be cleaner. |
I think this asserts correctly as Brock mentions. Closing |
xref #13288
We should assert that we have a valid dtype in the constructed object (so should do this in
_simple_new
to avoid these guarantee violations)The text was updated successfully, but these errors were encountered: