-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
REF: PandasColumn.describe_categorical returns categores instead of mapping #47886
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
Conversation
|
@vnlitvinov ok? |
rgommers
left a comment
There was a problem hiding this 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] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
xref: data-apis/dataframe-api#69
cc @shwina @vnlitvinov