Skip to content

pd.crosstab's handling of categorical variables #26822

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

Closed
kiwiPhrases opened this issue Jun 12, 2019 · 1 comment
Closed

pd.crosstab's handling of categorical variables #26822

kiwiPhrases opened this issue Jun 12, 2019 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request

Comments

@kiwiPhrases
Copy link

kiwiPhrases commented Jun 12, 2019

Code Sample

kyle = pd.DataFrame({'foo':np.random.randint(0,100,100),'boo':np.random.randint(0,100,100)})
kyle.loc[:,'fooCut'] = pd.qcut(kyle.loc[:,'foo'], np.arange(0,1.1,.1))
kyle.loc[:,'booCut'] = pd.qcut(kyle.loc[:,'boo'], np.arange(0,1.1,.1))

print(kyle.footCut.dtype)

pd.crosstab(kyle.fooCut,kyle.booCut)

Problem description

According to the documentation and previous versions of Pandas, pd.Crosstab handled categorical variables returned by pd.qcut but in version .24.2 pd.crosstab throws a TypeError even though both columns agree with the dtype presented in the documentation

@TomAugspurger
Copy link
Contributor

This is the same root problem as #25814. It's being fixed by #26765.

@TomAugspurger TomAugspurger added the Duplicate Report Duplicate issue or pull request label Jun 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants