-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
API: replace dropna=False option with na_sentinel=None in factorize #35852
API: replace dropna=False option with na_sentinel=None in factorize #35852
Conversation
Hello @charlesdong1991! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-09-02 14:12:23 UTC |
na_sentinel
keyword in pd.factorize
supports None
to include NaNs in the unique of valuesna_sentinel
keyword in pd.factorize
supports None
to include NaNs in the unique of values and remove dropna
keyword
na_sentinel
keyword in pd.factorize
supports None
to include NaNs in the unique of values and remove dropna
keywordThere 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.
minor comment, otherwise lgtm. ping on green.
If NaN is in the values, and we want to include NaN in the uniques of the | ||
values, it can be achieved by setting ``na_sentinel=None``. | ||
|
||
>>> values = np.array([1, 2, 1, np.nan]) |
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.
can you add the same example above this as well but w/o setting na_sentinel
pandas/core/algorithms.py
Outdated
values, it can be achieved by setting ``na_sentinel=None``. | ||
|
||
>>> values = np.array([1, 2, 1, np.nan]) | ||
>>> codes, uniques = pd.factorize(values) # default |
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.
>>> codes, uniques = pd.factorize(values) # default | |
>>> codes, uniques = pd.factorize(values) # default na_sentinel=-1 |
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.
if you can push this change and merge on green would be great.
array([ 0, 1, 0, -1]) | ||
>>> uniques | ||
array([1., 2.]) | ||
>>> codes, uniques = pd.factorize(values, na_sentinel=None) |
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.
ideally put a blank line as othewise this is very hard to read
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.
done!
@charlesdong1991 can ignore that 38_locale failure |
thanks @jreback Will ignore and merge it! |
@simonjayhawkins btw, i think should this be backported, right? |
@meeseeksdev backport 1.1.x |
…a_sentinel=None in factorize
yep. thanks. meeseeks... is only very occasionally picking these up now. |
i've got a branch going for automating the release process, but in the first instance am using it for release readiness, i'm planning to add a check shortly that the whatsnew on the backport and master are the same. so this should make sure that any PRs that change the whatsnew aren't missed. |
…=None in factorize (#36071) Co-authored-by: Kaiqi Dong <[email protected]>
That would be cool! |
…andas-dev#35852) * remove \n from docstring * fix issue 17038 * revert change * revert change * add dropna doc for factorize * rephrase the doc * flake8 * fixup * use NaN * add dropna in series.factorize * black * add test * linting * linting * doct * fix black * fixup * fix doctest * add whatsnew * linting * fix test * try one time * hide dropna and use na_sentinel=None * update whatsnew * rename test function * remove dropna from factorize * update doc * docstring * update doc * add comment * code change on review * update doc * code change on review * minor move in whatsnew * add default example * doc * one more try * explicit doc * add space
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff