-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: inconsistent behavior on multi-dimensional slicing based on type #45303
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
This goes through
This goes through IIRC the plan is to enforce the deprecation in 2.0 so these would both raise.
Do you need |
We currently have a bunch of complicated warning contexts / try ... excepts to handle this, if both raised we would be perfectly happy! The issue is that we were not catching The context we are using this in is https://github.com/matplotlib/matplotlib/blob/8d7a2b9d2a38f01ee0d6802dd4f9e98aec812322/lib/matplotlib/cbook/__init__.py#L1301-L1343 . We are using the failure of We are also open to better suggestions about how to handle this (without importing pandas). I guess we would do some #30588 is probably also relevant. |
Both will raise in 2.0. I'm not sure if we have pinned down exactly what type of exception will be raised, but ValueError seems like a reasonable option.
With the appropriate caveats about relying on implementation details: most (non-scalar) pandas classes have a "_typ: str" attribute that are used to bootstrap |
To add a new dimension to the existing data frame, by using values method we could do it. series will be failed to add dimension, Here everything depends on the series type we use. Float series type has that issue not the Integer. |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
Issue Description
Per discussion around #35527 / https://github.com/matplotlib/matplotlib/issues/18158and related links there have been a bunch of issues about multi-dimensional indexing in to
Series
and objects that have inconsistent.ndims
and.shape
.In a departure from
numpy
it was my understanding that the implicit broadcasting to higher dimensions was going to be dropped by pandas at some point in the future (although it seems to still warn for builtin types). However, for the new missing-data types trying to do this 2D slicing raises aValueError
which was reported as a bug to Matplotlib matplotlib/matplotlib#22125Given
I think we need to revisit this and make sure we are not both grumbling about the other and putting in dueling workarounds ;)
Expected Behavior
Behavior of the container to be independent of the contained type.
Installed Versions
I have broken distutils and pd.show_versions() fails in a weird way?
The text was updated successfully, but these errors were encountered: