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 the copy kw from .xs to prevent an expectation of a view (which may not be possible) #6919

Merged
merged 1 commit into from
Apr 22, 2014

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Apr 22, 2014

closes #6894

Deprecate passing keyword copy to:

  • DataFrame/Series/Panel/.xs
  • Panel.minor_xs
  • Panel.major_xs

.xs returns a view (as does .loc) IF POSSIBLE

MultiIndexing with Slicers eliminates the need for this (and .xs for the too, but for
some cases its 'simpler').

@jreback jreback added this to the 0.14.0 milestone Apr 22, 2014
@jorisvandenbossche
Copy link
Member

Should we go first through a deprecation cycle? So to not let fail your code when you provided the copy keyword, but only warning it is ignored and will be removed?

@jreback
Copy link
Contributor Author

jreback commented Apr 22, 2014

good point..will add on the user facing code

@jreback
Copy link
Contributor Author

jreback commented Apr 22, 2014

@jorisvandenbossche updated.....so this still allows one to do

df.xs('foo')[:] = 10

but now is undocumented (was in a doc string before)
(and will give a SettingWithCopyWarning if its actually a copy, rather than a view).

But that is not supported / dangerous anyhow

MultiIndex Slicers is the correct method

df.loc['foo'] = 10

so nothing lost

maybe should add to the doc string that .xs is only for getting?

@jreback
Copy link
Contributor Author

jreback commented Apr 22, 2014

@jorisvandenbossche how do I do a See also and have it refer to loc? in the docstring (so you can click it)

@jreback
Copy link
Contributor Author

jreback commented Apr 22, 2014

@jorisvandenbossche

can I use a :ref: directly in the See Also?

e.g.

For more information on ``.at``, ``.iat``, ``.ix``, ``.loc``, and
``.iloc``,  see the :ref:`indexing documentation <indexing>`.

@jorisvandenbossche
Copy link
Member

like this:

See also
--------
DataFrame.loc : some explanation why this would be related

only the docstring of loc is not that informative ... (http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.loc.html#pandas.DataFrame.loc) maybe should open an issue about that

@jreback
Copy link
Contributor Author

jreback commented Apr 22, 2014

just did #6920

@jorisvandenbossche
Copy link
Member

Aha :-)

Yes, you can use all sphinx referencing in the docstrings as in the normal docs (only if you see the docstring as plain text in eg the terminal, then it makes less sense, but for the api pages on the online docs this is very useful)

@jreback
Copy link
Contributor Author

jreback commented Apr 22, 2014

gr8..makes sense

@jorisvandenbossche
Copy link
Member

Maybe explicitly add in the description of xs is only for getting? I found that a good idea.
And the See also has to be a Notes now ('see also' is really only for python/pandas objects that sphinx can make a link to, and not for a general sentence)

jreback added a commit that referenced this pull request Apr 22, 2014
API: remove the copy kw from .xs to prevent an expectation of a view (which may not be possible)
@jreback jreback merged commit a9ee7f4 into pandas-dev:master Apr 22, 2014
jreback pushed a commit that referenced this pull request Jul 25, 2016
Title is self-explanatory.  Picks up where #6919 left off.

Author: gfyoung <gfyoung17@gmail.com>

Closes #13781 from gfyoung/xs-copy-remove and squashes the following commits:

c314bc1 [gfyoung] CLN: Removed copy parameter in xs_* methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.13.1: DataFrame.xs() ValueError: Cannot retrieve view (copy=False)
3 participants