Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: Preserve nullable boolean dtype in pivot_table (GH#62244) #62256

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

Copy link
Contributor

@skalwaghe-56 skalwaghe-56 commented Sep 5, 2025
edited
Loading


ENH: Preserve nullable boolean dtype in pivot_table (GH#62244)

This PR ensures pivot_table preserves nullable boolean dtype instead of upcasting to float
for boolean columns or object columns containing only booleans. It also skips dtype conversion
for margin columns that are returned as DataFrames.

Includes updated test_pivot_table_bool_preserves_boolean_dtype with safe assertions
(assert / assert not) to comply with linting rules.

Copy link
Contributor Author

@jbrockmendel Please let me know if it needs any other changes.

Copy link
Contributor Author

@jbrockmendel Updated the documentation too! Let me know if this needs any other changes.

@skalwaghe-56 skalwaghe-56 force-pushed the fix-62244-unstack-bool-dtype-memory branch from 59565e6 to 95b4f5a Compare September 5, 2025 08:33
Copy link
Member

jbrockmendel commented Sep 5, 2025
edited
Loading

Nullable dtypes are opt-in. We don't silently cast to them. This issue will probably go un-resolved until PDEP16 is fully implemented.

@skalwaghe-56 skalwaghe-56 marked this pull request as draft September 6, 2025 07:05
- Convert bool/object columns to BooleanDtype
- Skip dtype conversion for margin columns that are DataFrames
- Updated test_pivot_table_bool_preserves_boolean_dtype with safe assertions
- Added release note to v3.0.0.rst under Enhancements and Bug fixes, describing that boolean columns are now preserved as nullable BooleanDtype in pivoting and unstacking operations, with missing values as pd.NA.
- References issue pandas-dev#62244.
@skalwaghe-56 skalwaghe-56 force-pushed the fix-62244-unstack-bool-dtype-memory branch from 990800f to 98ac57d Compare September 6, 2025 07:05
Copy link
Contributor Author

@jbrockmendel What do you suggest we do? Close this PR or keep it open? Thank you for your guidance!

Copy link
Member

Close it, yes.

Copy link
Contributor Author

@jbrockmendel Closing the PR. Thank you!

@skalwaghe-56 skalwaghe-56 deleted the fix-62244-unstack-bool-dtype-memory branch September 6, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

PERF: DataFrame.unstack() and DataFrame.pivot_table() upcasting take up more memory than needed

AltStyle によって変換されたページ (->オリジナル) /