@@ -688,43 +688,67 @@ def _combine_panel(self, other, func):
688
688
689
689
return self ._constructor (result_values , items , major , minor )
690
690
691
- def major_xs (self , key , copy = True ):
691
+ def major_xs (self , key , copy = None ):
692
692
"""
693
693
Return slice of panel along major axis
694
694
695
695
Parameters
696
696
----------
697
697
key : object
698
698
Major axis label
699
- copy : boolean, default True
700
- Copy data
699
+ copy : boolean [deprecated]
700
+ Whether to make a copy of the data
701
701
702
702
Returns
703
703
-------
704
704
y : DataFrame
705
705
index -> minor axis, columns -> items
706
+
707
+ Notes
708
+ -----
709
+ major_xs is only for getting, not setting values.
710
+
711
+ MultiIndex Slicers is a generic way to get/set values on any level or levels
712
+ it is a superset of major_xs functionality, see :ref:`MultiIndex Slicers <indexing.mi_slicers>`
713
+
706
714
"""
707
- return self .xs (key , axis = self ._AXIS_LEN - 2 , copy = copy )
715
+ if copy is not None :
716
+ warnings .warn ("copy keyword is deprecated, "
717
+ "default is to return a copy or a view if possible" )
708
718
709
- def minor_xs (self , key , copy = True ):
719
+ return self .xs (key , axis = self ._AXIS_LEN - 2 )
720
+
721
+ def minor_xs (self , key , copy = None ):
710
722
"""
711
723
Return slice of panel along minor axis
712
724
713
725
Parameters
714
726
----------
715
727
key : object
716
728
Minor axis label
717
- copy : boolean, default True
718
- Copy data
729
+ copy : boolean [deprecated]
730
+ Whether to make a copy of the data
719
731
720
732
Returns
721
733
-------
722
734
y : DataFrame
723
735
index -> major axis, columns -> items
736
+
737
+ Notes
738
+ -----
739
+ minor_xs is only for getting, not setting values.
740
+
741
+ MultiIndex Slicers is a generic way to get/set values on any level or levels
742
+ it is a superset of minor_xs functionality, see :ref:`MultiIndex Slicers <indexing.mi_slicers>`
743
+
724
744
"""
725
- return self .xs (key , axis = self ._AXIS_LEN - 1 , copy = copy )
745
+ if copy is not None :
746
+ warnings .warn ("copy keyword is deprecated, "
747
+ "default is to return a copy or a view if possible" )
748
+
749
+ return self .xs (key , axis = self ._AXIS_LEN - 1 )
726
750
727
- def xs (self , key , axis = 1 , copy = True ):
751
+ def xs (self , key , axis = 1 , copy = None ):
728
752
"""
729
753
Return slice of panel along selected axis
730
754
@@ -733,24 +757,36 @@ def xs(self, key, axis=1, copy=True):
733
757
key : object
734
758
Label
735
759
axis : {'items', 'major', 'minor}, default 1/'major'
736
- copy : boolean, default True
737
- Copy data
760
+ copy : boolean [deprecated]
761
+ Whether to make a copy of the data
738
762
739
763
Returns
740
764
-------
741
765
y : ndim(self)-1
766
+
767
+ Notes
768
+ -----
769
+ xs is only for getting, not setting values.
770
+
771
+ MultiIndex Slicers is a generic way to get/set values on any level or levels
772
+ it is a superset of xs functionality, see :ref:`MultiIndex Slicers <indexing.mi_slicers>`
773
+
742
774
"""
775
+ if copy is not None :
776
+ warnings .warn ("copy keyword is deprecated, "
777
+ "default is to return a copy or a view if possible" )
778
+
743
779
axis = self ._get_axis_number (axis )
744
780
if axis == 0 :
745
- data = self [key ]
746
- if copy :
747
- data = data .copy ()
748
- return data
781
+ return self [key ]
749
782
750
783
self ._consolidate_inplace ()
751
784
axis_number = self ._get_axis_number (axis )
752
- new_data = self ._data .xs (key , axis = axis_number , copy = copy )
753
- return self ._construct_return_type (new_data )
785
+ new_data = self ._data .xs (key , axis = axis_number , copy = False )
786
+ result = self ._construct_return_type (new_data )
787
+ copy = new_data .is_mixed_type
788
+ result ._set_is_copy (self , copy = copy )
789
+ return result
754
790
755
791
_xs = xs
756
792
0 commit comments