Skip to content

BUG: crosstab with margins=True and dropna=False #12642

Closed
@jreback

Description

@jreback

xref #12614

In [1]: df = pd.DataFrame({'a': [1, 2, 2, 2, 2, np.nan],'b': [3, 3, 4, 4, 4, 4]})

In [2]: pd.crosstab(df.a, df.b, margins=True, dropna=True)
Out[2]: 
b    3  4  All
a             
1.0  1  0    1
2.0  1  3    4
All  2  3    5

In [3]: pd.crosstab(df.a, df.b, margins=True, dropna=False)
KeyError: 'Level None not found'

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions