Skip to content

pd.crosstab's handling of categorical variables #26822

Closed
@kiwiPhrases

Description

@kiwiPhrases

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions