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
Closed

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

jreback opened this issue Mar 16, 2016 · 3 comments
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@jreback
Copy link
Contributor

jreback 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 jreback added Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode Difficulty Intermediate labels Mar 16, 2016
@jreback jreback added this to the 0.18.1 milestone Mar 16, 2016
@jreback
Copy link
Contributor Author

jreback commented Mar 16, 2016

also let's tests with a multi-index

@jreback
Copy link
Contributor Author

jreback commented Mar 16, 2016

cc @OXPHOS

@OXPHOS
Copy link
Contributor

OXPHOS 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
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
2 participants