Skip to content

Commit c314bc1

Browse files
committed
CLN: Removed copy parameter in xs_* methods
1 parent 474fd05 commit c314bc1

File tree

4 files changed

+8
-38
lines changed

4 files changed

+8
-38
lines changed

doc/source/whatsnew/v0.19.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ Removal of prior version deprecations/changes
625625
- ``DataFrame.to_sql()`` has dropped the ``mysql`` option for the ``flavor`` parameter (:issue:`13611`)
626626
- ``pd.Index`` has dropped the ``diff`` method in favour of ``difference`` (:issue:`13669`)
627627

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

pandas/core/generic.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ def take(self, indices, axis=0, convert=True, is_copy=True, **kwargs):
16711671

16721672
return result
16731673

1674-
def xs(self, key, axis=0, level=None, copy=None, drop_level=True):
1674+
def xs(self, key, axis=0, level=None, drop_level=True):
16751675
"""
16761676
Returns a cross-section (row(s) or column(s)) from the
16771677
Series/DataFrame. Defaults to cross-section on the rows (axis=0).
@@ -1685,8 +1685,6 @@ def xs(self, key, axis=0, level=None, copy=None, drop_level=True):
16851685
level : object, defaults to first n levels (n=1 or len(key))
16861686
In case of a key partially contained in a MultiIndex, indicate
16871687
which levels are used. Levels can be referred by label or position.
1688-
copy : boolean [deprecated]
1689-
Whether to make a copy of the data
16901688
drop_level : boolean, default True
16911689
If False, returns object with same levels as self.
16921690
@@ -1742,10 +1740,6 @@ def xs(self, key, axis=0, level=None, copy=None, drop_level=True):
17421740
:ref:`MultiIndex Slicers <advanced.mi_slicers>`
17431741
17441742
"""
1745-
if copy is not None:
1746-
warnings.warn("copy keyword is deprecated, "
1747-
"default is to return a copy or a view if possible")
1748-
17491743
axis = self._get_axis_number(axis)
17501744
labels = self._get_axis(axis)
17511745
if level is not None:
@@ -1800,9 +1794,9 @@ def xs(self, key, axis=0, level=None, copy=None, drop_level=True):
18001794
if not is_list_like(new_values) or self.ndim == 1:
18011795
return _maybe_box_datetimelike(new_values)
18021796

1803-
result = self._constructor_sliced(new_values, index=self.columns,
1804-
name=self.index[loc], copy=copy,
1805-
dtype=new_values.dtype)
1797+
result = self._constructor_sliced(
1798+
new_values, index=self.columns,
1799+
name=self.index[loc], dtype=new_values.dtype)
18061800

18071801
else:
18081802
result = self.iloc[loc]

pandas/core/panel.py

+3-21
Original file line numberDiff line numberDiff line change
@@ -758,16 +758,14 @@ def _combine_panel(self, other, func):
758758

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

761-
def major_xs(self, key, copy=None):
761+
def major_xs(self, key):
762762
"""
763763
Return slice of panel along major axis
764764
765765
Parameters
766766
----------
767767
key : object
768768
Major axis label
769-
copy : boolean [deprecated]
770-
Whether to make a copy of the data
771769
772770
Returns
773771
-------
@@ -783,22 +781,16 @@ def major_xs(self, key, copy=None):
783781
:ref:`MultiIndex Slicers <advanced.mi_slicers>`
784782
785783
"""
786-
if copy is not None:
787-
warnings.warn("copy keyword is deprecated, "
788-
"default is to return a copy or a view if possible")
789-
790784
return self.xs(key, axis=self._AXIS_LEN - 2)
791785

792-
def minor_xs(self, key, copy=None):
786+
def minor_xs(self, key):
793787
"""
794788
Return slice of panel along minor axis
795789
796790
Parameters
797791
----------
798792
key : object
799793
Minor axis label
800-
copy : boolean [deprecated]
801-
Whether to make a copy of the data
802794
803795
Returns
804796
-------
@@ -814,13 +806,9 @@ def minor_xs(self, key, copy=None):
814806
:ref:`MultiIndex Slicers <advanced.mi_slicers>`
815807
816808
"""
817-
if copy is not None:
818-
warnings.warn("copy keyword is deprecated, "
819-
"default is to return a copy or a view if possible")
820-
821809
return self.xs(key, axis=self._AXIS_LEN - 1)
822810

823-
def xs(self, key, axis=1, copy=None):
811+
def xs(self, key, axis=1):
824812
"""
825813
Return slice of panel along selected axis
826814
@@ -829,8 +817,6 @@ def xs(self, key, axis=1, copy=None):
829817
key : object
830818
Label
831819
axis : {'items', 'major', 'minor}, default 1/'major'
832-
copy : boolean [deprecated]
833-
Whether to make a copy of the data
834820
835821
Returns
836822
-------
@@ -845,10 +831,6 @@ def xs(self, key, axis=1, copy=None):
845831
:ref:`MultiIndex Slicers <advanced.mi_slicers>`
846832
847833
"""
848-
if copy is not None:
849-
warnings.warn("copy keyword is deprecated, "
850-
"default is to return a copy or a view if possible")
851-
852834
axis = self._get_axis_number(axis)
853835
if axis == 0:
854836
return self[key]

pandas/tests/test_panel.py

-7
Original file line numberDiff line numberDiff line change
@@ -2597,13 +2597,6 @@ def test_panel_index():
25972597
tm.assert_index_equal(index, expected)
25982598

25992599

2600-
def test_import_warnings():
2601-
# GH8152
2602-
panel = Panel(np.random.rand(3, 3, 3))
2603-
with assert_produces_warning():
2604-
panel.major_xs(1, copy=False)
2605-
2606-
26072600
if __name__ == '__main__':
26082601
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
26092602
exit=False)

0 commit comments

Comments
 (0)