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

REF: PandasColumn.describe_categorical returns categores instead of mapping #47886

Merged
merged 7 commits into from
Aug 12, 2022

Conversation

mroeschke
Copy link
Member

xref: data-apis/dataframe-api#69

cc @shwina @vnlitvinov

@mroeschke mroeschke added the Interchange Dataframe Interchange Protocol label Jul 28, 2022
@mroeschke mroeschke added this to the 1.5 milestone Jul 28, 2022
@jreback
Copy link
Contributor

jreback commented Aug 2, 2022

@vnlitvinov ok?

Copy link
Contributor

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. One small comment on a static typing issue.

mapping = categorical["mapping"]
assert isinstance(mapping, dict), "Categorical mapping must be a dict"
categories = np.array(tuple(mapping[k] for k in sorted(mapping)))
categories = np.array(categorical["categories"]._col) # type:ignore[union-attr]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assert above looks like it was there to help Mypy (type narrows the union to the actual type, before a dict and now an np.array). Did you try updating rather than removing it? It may remove the need for this type:ignore and the entry in the pyright_ file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch! Added back an assertion to prevent ignoring typing here.

@jreback jreback merged commit 396ad41 into pandas-dev:main Aug 12, 2022
@mroeschke mroeschke deleted the exchange/update branch August 12, 2022 00:15
YYYasin19 pushed a commit to YYYasin19/pandas that referenced this pull request Aug 23, 2022
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Interchange Dataframe Interchange Protocol
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants