Skip to content
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
14 changes: 11 additions & 3 deletions doc/source/user_guide/reshaping.rst
Original file line number Diff line number Diff line change
Expand Up @@ -471,16 +471,24 @@ If ``crosstab`` receives only two Series, it will provide a frequency table.

pd.crosstab(df['A'], df['B'])

Any input passed containing ``Categorical`` data will have **all** of its
categories included in the cross-tabulation, even if the actual data does
not contain any instances of a particular category.
``crosstab`` can also be implemented
to ``Categorical`` data.

.. ipython:: python

foo = pd.Categorical(['a', 'b'], categories=['a', 'b', 'c'])
bar = pd.Categorical(['d', 'e'], categories=['d', 'e', 'f'])
pd.crosstab(foo, bar)

If you want to include **all** of data categories even if the actual data does
not contain any instances of a particular category, you should set ``dropna=False``.

For example:

.. ipython:: python

pd.crosstab(foo, bar, dropna=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

can u put this one in a separate ipython block and put the comment before that one


Normalization
~~~~~~~~~~~~~

Expand Down