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

Implement deep copy option in Series.copy #2721

Closed
hughesadam87 opened this issue Jan 21, 2013 · 9 comments
Closed

Implement deep copy option in Series.copy #2721

hughesadam87 opened this issue Jan 21, 2013 · 9 comments

Comments

@hughesadam87
Copy link

Not quite sure if this is intentional behavior, but noticed that df.copy() accepts argument deep and series.copy() does not.

from pandas import Series, DataFrame
s=Series([1,2,3])
df=DataFrame(s)
df.copy(deep=True)
0
0 1
1 2
2 3
s.copy(deep=True)
Traceback (most recent call last):
File "", line 1, in
TypeError: copy() got an unexpected keyword argument 'deep'

@wesm
Copy link
Member

wesm commented Jan 21, 2013

Just hasn't been implemented

@cpcloud
Copy link
Member

cpcloud commented Jul 29, 2013

i think this might be simple after series inherits ndframe

@jreback
Copy link
Contributor

jreback commented Jul 29, 2013

closing in favor of #4324, side note, IIRC deep copy should also do a deep copy of the axes (currently it does not), or is that a separate option / action?

@jreback jreback closed this as completed Jul 29, 2013
@jtratner
Copy link
Contributor

@jreback probably should. (and index probably needs to take an option to deepcopy as well - since generally just copying metadata is enough)

@jreback
Copy link
Contributor

jreback commented Jul 29, 2013

@jtratner

df.copy(deep=True,axes=True) ?

or if deep=True then always copy axes, otherwise don't?

@jtratner
Copy link
Contributor

After the PR about multi index naming (which tweaks how copying works for Index) is merged it should:

  • deep copy axis when deep copying
  • shallow copy axis (ie call view) on copy without deep=True

I guess you could pass kwarg for axes but it should default to True, and at the minimum should always shallow copy (which just copies metadata) because contract for objects with axes is/should bw that they can manipulate them in place without any checks.

@jreback
Copy link
Contributor

jreback commented Aug 21, 2013

@jtrater just hit this with a Series.copy(deep=True) (which is part of rename!)

@jtratner
Copy link
Contributor

@jreback what? confused.

@jreback
Copy link
Contributor

jreback commented Aug 21, 2013

no, what I mean is I hit your error message! (was trying to do something funky)....doesn't matter...fixed

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

No branches or pull requests

5 participants