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

Deprecate inplace in Categorical.remove_unused_categories #37918

Merged
merged 5 commits into from
Nov 18, 2020

Conversation

OlehKSS
Copy link
Contributor

@OlehKSS OlehKSS commented Nov 17, 2020

  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Related to #37643

@@ -1083,8 +1093,7 @@ def remove_unused_categories(self, inplace=False):
cat._dtype = new_dtype
cat._codes = coerce_indexer_dtype(inv, new_dtype.categories)

if not inplace:
return cat
Copy link
Member

Choose a reason for hiding this comment

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

this doesnt get changed until we actually enforce the deprecation a few versions from now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

@@ -354,7 +354,7 @@ def test_validate_inplace_raises(self, value):
with pytest.raises(ValueError, match=msg):
cat.remove_categories(removals=["D", "E", "F"], inplace=value)

with pytest.raises(ValueError, match=msg):
with tm.assert_produces_warning(FutureWarning):
cat.remove_unused_categories(inplace=value)
Copy link
Member

Choose a reason for hiding this comment

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

comment inside this block about why we're getting a FutureWarning.

im guessing this actually needs both the raises and the produces_warning, ie.

with pytest.raises(ValueError, match=msg):
    with tm.assert_produces_warning(FutureWarning):
        # GH#37918 inplace kwarg deprecated
        cat.remove_unused_categories(inplace=value)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

@jbrockmendel
Copy link
Member

This is a very good start. For the checkbox at the top, since this doesn't handle all the relevant methods, it doesn't close the issue. Instead write below the checkboxes "xref #37643"

@OlehKSS
Copy link
Contributor Author

OlehKSS commented Nov 18, 2020

@jbrockmendel Thanks for a quick review, I have updated this pull request according to your suggestions

@pep8speaks
Copy link

pep8speaks commented Nov 18, 2020

Hello @OlehKSS! 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-11-18 11:57:24 UTC

@jreback jreback added Categorical Categorical Data Type Deprecate Functionality to remove in pandas labels Nov 18, 2020
@jreback jreback added this to the 1.2 milestone Nov 18, 2020
@jreback jreback merged commit 971f4ff into pandas-dev:master Nov 18, 2020
@jreback
Copy link
Contributor

jreback commented Nov 18, 2020

thanks @OlehKSS happy to have you do the rest ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Deprecate Functionality to remove in pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants