Skip to content

DEPR: dropna in pivot_table and crosstab#64759

Draft
jbrockmendel wants to merge 3 commits intopandas-dev:mainfrom
jbrockmendel:depr-53521
Draft

DEPR: dropna in pivot_table and crosstab#64759
jbrockmendel wants to merge 3 commits intopandas-dev:mainfrom
jbrockmendel:depr-53521

Conversation

@jbrockmendel
Copy link
Member

Summary

  • Deprecate the dropna parameter in pivot_table and crosstab with Pandas4Warning (GH#53521)
  • Fix bug where observed=dropna was incorrectly passed to _add_margins in pivot_table, ignoring the user's observed setting
  • Fix same observed=dropna coupling in crosstab
  • Add observed parameter to crosstab (previously unavailable)

closes #53521

Test plan

  • All existing pivot_table and crosstab tests pass (246 passed, 3 xfailed)
  • Tests that explicitly pass dropna= are wrapped with tm.assert_produces_warning(Pandas4Warning)
  • Pre-commit hooks pass

🤖 Generated with Claude Code

jbrockmendel and others added 3 commits March 21, 2026 18:19
…ions

Replace kh_get + kh_put patterns with kh_put alone (checking ret for
new-vs-existing), removing a redundant hash computation and probe
per element in value_count, _unique, duplicated(keep=False), and
get_labels_groupby.

Also clean up the vendored khash.h:
- Remove dead deletion-tracking code from kh_put/kh_get (deletions
  are disabled via __ac_isdel=0, but site variable and branches remained)
- Fix kh_clear to use 0xff (all-empty) instead of 0xaa, which was a
  leftover from the original 2-bit-per-slot flag scheme
- Remove unreachable shrink path from kh_put resize trigger
- Fix value_count object pre-sizing from n//10 to n

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jbrockmendel jbrockmendel added the Deprecate Functionality to remove in pandas label Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Deprecate Functionality to remove in pandas

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DEPR: Some dropna behaviors in DataFrame.pivot_table

1 participant