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

CLN: Removed copy parameter in xs_* methods #13781

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.19.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ Removal of prior version deprecations/changes
- ``DataFrame.to_sql()`` has dropped the ``mysql`` option for the ``flavor`` parameter (:issue:`13611`)
- ``pd.Index`` has dropped the ``diff`` method in favour of ``difference`` (:issue:`13669`)

- ``Series.xs``, ``DataFrame.xs``, ``Panel.xs``, ``Panel.major_xs``, and ``Panel.minor_xs`` have dropped the ``copy`` parameter (:issue:`13781`)
- ``str.split`` has dropped the ``return_type`` parameter in favor of ``expand`` (:issue:`13701`)
- Removal of the legacy time rules (offset aliases), deprecated since 0.17.0 (this has been alias since 0.8.0) (:issue:`13590`)

Expand Down
14 changes: 4 additions & 10 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1671,7 +1671,7 @@ def take(self, indices, axis=0, convert=True, is_copy=True, **kwargs):

return result

def xs(self, key, axis=0, level=None, copy=None, drop_level=True):
def xs(self, key, axis=0, level=None, drop_level=True):
"""
Returns a cross-section (row(s) or column(s)) from the
Series/DataFrame. Defaults to cross-section on the rows (axis=0).
Expand All @@ -1685,8 +1685,6 @@ def xs(self, key, axis=0, level=None, copy=None, drop_level=True):
level : object, defaults to first n levels (n=1 or len(key))
In case of a key partially contained in a MultiIndex, indicate
which levels are used. Levels can be referred by label or position.
copy : boolean [deprecated]
Whether to make a copy of the data
drop_level : boolean, default True
If False, returns object with same levels as self.

Expand Down Expand Up @@ -1742,10 +1740,6 @@ def xs(self, key, axis=0, level=None, copy=None, drop_level=True):
:ref:`MultiIndex Slicers <advanced.mi_slicers>`

"""
if copy is not None:
warnings.warn("copy keyword is deprecated, "
"default is to return a copy or a view if possible")

axis = self._get_axis_number(axis)
labels = self._get_axis(axis)
if level is not None:
Expand Down Expand Up @@ -1800,9 +1794,9 @@ def xs(self, key, axis=0, level=None, copy=None, drop_level=True):
if not is_list_like(new_values) or self.ndim == 1:
return _maybe_box_datetimelike(new_values)

result = self._constructor_sliced(new_values, index=self.columns,
name=self.index[loc], copy=copy,
dtype=new_values.dtype)
result = self._constructor_sliced(
new_values, index=self.columns,
name=self.index[loc], dtype=new_values.dtype)

else:
result = self.iloc[loc]
Expand Down
24 changes: 3 additions & 21 deletions pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,16 +758,14 @@ def _combine_panel(self, other, func):

return self._constructor(result_values, items, major, minor)

def major_xs(self, key, copy=None):
def major_xs(self, key):
"""
Return slice of panel along major axis

Parameters
----------
key : object
Major axis label
copy : boolean [deprecated]
Whether to make a copy of the data

Returns
-------
Expand All @@ -783,22 +781,16 @@ def major_xs(self, key, copy=None):
:ref:`MultiIndex Slicers <advanced.mi_slicers>`

"""
if copy is not None:
warnings.warn("copy keyword is deprecated, "
"default is to return a copy or a view if possible")

return self.xs(key, axis=self._AXIS_LEN - 2)

def minor_xs(self, key, copy=None):
def minor_xs(self, key):
"""
Return slice of panel along minor axis

Parameters
----------
key : object
Minor axis label
copy : boolean [deprecated]
Whether to make a copy of the data

Returns
-------
Expand All @@ -814,13 +806,9 @@ def minor_xs(self, key, copy=None):
:ref:`MultiIndex Slicers <advanced.mi_slicers>`

"""
if copy is not None:
warnings.warn("copy keyword is deprecated, "
"default is to return a copy or a view if possible")

return self.xs(key, axis=self._AXIS_LEN - 1)

def xs(self, key, axis=1, copy=None):
def xs(self, key, axis=1):
"""
Return slice of panel along selected axis

Expand All @@ -829,8 +817,6 @@ def xs(self, key, axis=1, copy=None):
key : object
Label
axis : {'items', 'major', 'minor}, default 1/'major'
copy : boolean [deprecated]
Whether to make a copy of the data

Returns
-------
Expand All @@ -845,10 +831,6 @@ def xs(self, key, axis=1, copy=None):
:ref:`MultiIndex Slicers <advanced.mi_slicers>`

"""
if copy is not None:
warnings.warn("copy keyword is deprecated, "
"default is to return a copy or a view if possible")

axis = self._get_axis_number(axis)
if axis == 0:
return self[key]
Expand Down
7 changes: 0 additions & 7 deletions pandas/tests/test_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2597,13 +2597,6 @@ def test_panel_index():
tm.assert_index_equal(index, expected)


def test_import_warnings():
# GH8152
panel = Panel(np.random.rand(3, 3, 3))
with assert_produces_warning():
panel.major_xs(1, copy=False)


if __name__ == '__main__':
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
exit=False)