Skip to content

DEPR: is_copy arg of take closes #27357 #28751

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

chrisstpierre
Copy link

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Minor comments but generally very nice! Can you also add a whatsnew note for 1.0.0?

@@ -3372,6 +3372,8 @@ def take(self, indices, axis=0, is_copy=True, **kwargs):
selecting rows, ``1`` means that we are selecting columns.
is_copy : bool, default True
Whether to return a copy of the original object or not.

.. deprecated:: 0.25.2
Copy link
Member

Choose a reason for hiding this comment

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

Should be 1.0.0 at this point

FutureWarning,
stacklevel=2,
)
is_copy = True
Copy link
Member

Choose a reason for hiding this comment

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

Is this assignment even required? Not used later in the function body right?

Copy link
Member

Choose a reason for hiding this comment

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

There is a if is_copy: a few lines below

Copy link
Member

Choose a reason for hiding this comment

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

But, we should only put it to True if it was None (to keep the existing behaviour), so put it in an else block ?

Copy link
Author

Choose a reason for hiding this comment

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

It is used:

        # Maybe set copy if we didn't actually change the index.
        if is_copy:
            if not result._get_axis(axis).equals(self._get_axis(axis)):
                result._set_is_copy(self)
        return result

But is_copy is already deprecated. I think it needs to be removed for 1.0. Since this is going into 1.0 I am thinking now that instead of deprecating this parameter it needs to be removed all together, along with is_copy ?

@WillAyd WillAyd added the Deprecate Functionality to remove in pandas label Oct 2, 2019
@WillAyd WillAyd added this to the 1.0 milestone Oct 2, 2019
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

FutureWarning,
stacklevel=2,
)
is_copy = True
Copy link
Member

Choose a reason for hiding this comment

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

But, we should only put it to True if it was None (to keep the existing behaviour), so put it in an else block ?

@@ -3430,6 +3432,14 @@ class max_speed
1 monkey mammal NaN
3 lion mammal 80.5
"""
if is_copy is not None:
warnings.warn(
"is_copy is deprecated and will be removed in a future version",
Copy link
Member

Choose a reason for hiding this comment

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

Can you add that 'take' will always return a copy in the future?

@@ -800,6 +800,11 @@ def test_take_invalid_kwargs(self):
with pytest.raises(ValueError, match=msg):
obj.take(indices, mode="clip")

def test_take_deprecated_kwarg_is_copy(self):
df = DataFrame([1, 2])
Copy link
Member

Choose a reason for hiding this comment

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

Reference issue number above

@WillAyd
Copy link
Member

WillAyd commented Nov 7, 2019

@chrisstpierre is this still active? If so can you merge master and repush?

@WillAyd
Copy link
Member

WillAyd commented Dec 9, 2019

Closing as I think this is stale but @chrisstpierre ping if you'd like to pick back up

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

Successfully merging this pull request may close these issues.

DEPR: .take(..., is_copy=True); rename is_copy -> copy
4 participants