Skip to content
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

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

Closed
jreback opened this issue Mar 16, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@jreback
Copy link
Contributor

commented Mar 16, 2016

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'
@jreback

This comment has been minimized.

Copy link
Contributor Author

commented Mar 16, 2016

also let's tests with a multi-index

@jreback

This comment has been minimized.

Copy link
Contributor Author

commented Mar 16, 2016

cc @OXPHOS

@OXPHOS

This comment has been minimized.

Copy link
Contributor

commented Mar 16, 2016

Thanks. I like that test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.