Skip to content
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

PERF: future_stack=True with non-MulitIndex columns #58817

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

rhshadrach
Copy link
Member

@rhshadrach rhshadrach commented May 24, 2024

@rhshadrach rhshadrach added Performance Memory or execution speed performance Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels May 24, 2024
@rhshadrach rhshadrach added this to the 3.0 milestone May 24, 2024
@rhshadrach
Copy link
Member Author

@jbrockmendel - the failing tests are:

FAILED pandas/tests/extension/test_numpy.py::TestNumpyExtensionArray::test_stack[float-True-columns0] - AssertionError: (<class 'numpy.dtypes.Float64DType'>, dtype('float64')) vs (<class 'pandas.core.dtypes.dtypes.NumpyEADtype'>, NumpyEADtype('float64'))
FAILED pandas/tests/extension/test_numpy.py::TestNumpyExtensionArray::test_stack[object-True-columns0] - AssertionError: (<class 'numpy.dtypes.ObjectDType'>, dtype('O')) vs (<class 'pandas.core.dtypes.dtypes.NumpyEADtype'>, NumpyEADtype('object'))

This happens because of some monkey-patching

https://github.com/pandas-dev/pandas/blame/3b48b17e52f3f3837b9ba8551c932f44633b5ff8/pandas/tests/extension/test_numpy.py#L72-L73

It's not clear to me if the code should handle this case, or if this behavior is okay and the test should be modified. Was wondering if you had any experience dealing with this.

Comment on lines +944 to +945
if len(frame.columns) > 0 and frame._is_homogeneous_type:
dtype = frame._mgr.blocks[0].dtype
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if there is a more canonical way to get the dtype in this case.

@jbrockmendel
Copy link
Member

The behavior is fine, the test should be patched

Copy link
Contributor

github-actions bot commented Jul 3, 2024

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Memory or execution speed performance Reshaping Concat, Merge/Join, Stack/Unstack, Explode Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PERF: df.unstack() is 500 times slower since pandas>=2.1
2 participants