Skip to content

add dropna=False to crosstab example #21413

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

Merged
merged 1 commit into from
Jun 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion pandas/core/reshape/pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,18 @@ def crosstab(index, columns, values=None, rownames=None, colnames=None,
>>> foo = pd.Categorical(['a', 'b'], categories=['a', 'b', 'c'])
>>> bar = pd.Categorical(['d', 'e'], categories=['d', 'e', 'f'])
>>> crosstab(foo, bar) # 'c' and 'f' are not represented in the data,
... # but they still will be counted in the output
# and will not be shown in the output because
# dropna is True by default. Set 'dropna=False'
# to preserve categories with no data
... # doctest: +SKIP
col_0 d e
row_0
a 1 0
b 0 1

>>> crosstab(foo, bar, dropna=False) # 'c' and 'f' are not represented
# in the data, but they still will be counted
# and shown in the output
... # doctest: +SKIP
col_0 d e f
row_0
Expand Down