Skip to content

TYP/CLN: factorize_from_iterable(s) #40775

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

Merged
merged 5 commits into from
Apr 5, 2021

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Apr 4, 2021

factorize_from_iterable didn't return an CategoricalIndex, if its input was a categorical-like. Instead it returned a plain Categorical. This PR fixes that + adds return types.

Also makes the return value for factorize_from_iterables clearer and easier to read.

"""
Factorize an input `values` into `categories` and `codes`. Preserves
categorical dtype in `categories`.

*This is an internal function*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needless info: by not being exposed outside of pd.core makes this an internal function. No need to be explicit.

@jreback jreback added Categorical Categorical Data Type Typing type annotations, mypy/pyright type checking labels Apr 5, 2021
@jreback jreback added this to the 1.3 milestone Apr 5, 2021
@jreback jreback merged commit 986c5ec into pandas-dev:master Apr 5, 2021
@jreback
Copy link
Contributor

jreback commented Apr 5, 2021

thanks @topper-123

vladu pushed a commit to vladu/pandas that referenced this pull request Apr 5, 2021
@topper-123 topper-123 deleted the type_factorize_from_iterable branch April 5, 2021 16:28
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants