-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPR: Enforce deprecation of ArrayManager #57118
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
Conversation
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.
@jbrockmendel - some comments and questions below
pandas/_typing.py
Outdated
SingleManager: TypeAlias = "SingleBlockManager" | ||
Manager2D: TypeAlias = "BlockManager" |
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.
Not sure if these are still useful - can remove
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.
Only useful if they are used elsewhere in the code
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.
They are used - but I'm not sure that makes them useful. We can replace any current usage of SingleManager with SingleBlockManager.
I tracked it down, this was added in #40152, so I think it makes sense to remove.
pandas/core/internals/managers.py
Outdated
@@ -289,6 +289,7 @@ def get_dtypes(self) -> npt.NDArray[np.object_]: | |||
dtypes = np.array([blk.dtype for blk in self.blocks], dtype=object) | |||
return dtypes.take(self.blknos) | |||
|
|||
# TODO: This is being used in a few places |
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'm seeing arrays being used in a few places, if this should still be removed then I'm thinking it's best for a followup.
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'm seeing this used in
- DataFrame._is_homogeneous_type
- DataFrame._reduce
- DataFrame._reduce_axis1
- DataFrame.shift
- NDFrame._logical_func
- NDFrame.astype
I'm thinking to just update the docstring for now, removing any mentions of the ArrayManager.
pandas/core/internals/managers.py
Outdated
# TODO: Cleanup? | ||
# Alias so we can share code with ArrayManager | ||
apply_with_block = apply |
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 this alias be removed?
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.
it can go, as can all of inernals.base IIRC
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.
Makes sense. Because part of the implementation needs to be moved from internals.base, I'd like to take that on in a followup.
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 only looked at _typing.py
pandas/_typing.py
Outdated
@@ -23,6 +23,7 @@ | |||
Optional, | |||
Protocol, | |||
Type as type_t, | |||
TypeAlias, |
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 not supported in python 3.9, so you should import it from typing_extensions
pandas/_typing.py
Outdated
SingleManager: TypeAlias = "SingleBlockManager" | ||
Manager2D: TypeAlias = "BlockManager" |
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.
Only useful if they are used elsewhere in the code
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.
Could you also remove PANDAS_DATA_MANAGER
in pandas/__init__.py
And add a whatsnew note in 3.0?
Thanks @Dr-Irv, @jbrockmendel, and @mroeschke. I think this is ready for another look. Two outstanding issues:
|
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 just looked at _typing.py
and I'm fine with that.
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.
Looks like a few more "mode.data_manager"
usages need to be removed
pandas/core/frame.py
Outdated
@@ -701,7 +696,7 @@ def __init__( | |||
# to avoid the result sharing the same Manager | |||
data = data.copy(deep=False) | |||
|
|||
if isinstance(data, (BlockManager, ArrayManager)): | |||
if isinstance(data, (BlockManager)): |
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.
extra parens
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.
other than this LGTM
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.
Thanks!
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.
Feel free to merge once the merge conflict is fixed
# Conflicts: # doc/source/whatsnew/v3.0.0.rst
Thanks @rhshadrach |
* DEPR: Enforce deprecation of ArrayManager * cleanups * More removals * whatsnew * Cleanups * More removals and whatsnew * cleanup
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.