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

API: remove deep keyword from EA.copy #27083

Merged
merged 5 commits into from
Jun 27, 2019

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Jun 27, 2019

Not clear on what type of deprecation cycle we want here

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

I would be ok with just making this change (no deprecation cycle), @jorisvandenbossche

@@ -101,10 +101,8 @@ def take(self, indexer, allow_fill=False, fill_value=None):
allow_fill=allow_fill)
return self._from_sequence(result)

def copy(self, deep=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a test in the pandas/tests/extension/constructors.py so it hits all EA's (for view & copy)

@jreback jreback added API Design ExtensionArray Extending pandas with custom dtypes or arrays. labels Jun 27, 2019
@jorisvandenbossche jorisvandenbossche changed the title remove deep keyword from EA.copy API: remove deep keyword from EA.copy Jun 27, 2019
@jorisvandenbossche
Copy link
Member

cc @TomAugspurger

Looks good to me. As usual (sorry ...), I would only add view() if we actually need it (meaning: use it internally)

"""
raise AbstractMethodError(self)

def view(self, dtype=None) -> ABCExtensionArray:
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

actually let's remove this for now @jbrockmendel

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

@jbrockmendel can you add a whatsnew note that remove the deep kwarg for EA

@jreback jreback added this to the 0.25.0 milestone Jun 27, 2019
@jorisvandenbossche
Copy link
Member

Slight preference for deprecation, but don't have strong thoughts here.

So a user only runs into this when they directly interface with an ExtensionArray themselves (as the uses within pandas get fixed). Further, for EA authors only implementing the EA itself, it's not a backwards incompatible change, as we don't have a problem that the EA still has the keyword, it will just never be called from inside pandas.

It seems that users doing Series.array.copy(deep=True) is something very specific, and also only introduced very recently (eg Categorical is longest out there, but has actually no copy keyword). IntegerArray and IntervalArray eg does have one.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Jun 27, 2019 via email

values = self.sp_values

def copy(self):
values = self.sp_values.copy()
return self._simple_new(values, self.sp_index, self.dtype)
Copy link
Member Author

Choose a reason for hiding this comment

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

@TomAugspurger do we need to copy the index here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not really sure. I don't know if they're designed for sharing across instances, or whether we mutate them inplace.

Copy link
Member

Choose a reason for hiding this comment

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

In any case in sparse.py, we don't mutate them inplace. I would also assume it is fine not to copy them.

@jreback
Copy link
Contributor

jreback commented Jun 27, 2019

lgtm. ping on green.

@jorisvandenbossche jorisvandenbossche merged commit b387da8 into pandas-dev:master Jun 27, 2019
@jorisvandenbossche
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Non-Deep copy for Categorical?
4 participants