11
11
from pandas .core .dtypes .common import (
12
12
ensure_platform_int , is_float , is_integer , is_integer_dtype , is_iterator ,
13
13
is_list_like , is_numeric_dtype , is_scalar , is_sequence , is_sparse )
14
- from pandas .core .dtypes .generic import ABCDataFrame , ABCPanel , ABCSeries
14
+ from pandas .core .dtypes .generic import ABCDataFrame , ABCSeries
15
15
from pandas .core .dtypes .missing import _infer_fill_value , isna
16
16
17
17
import pandas .core .common as com
@@ -450,10 +450,6 @@ def _setitem_with_indexer(self, indexer, value):
450
450
self .obj ._maybe_update_cacher (clear = True )
451
451
return self .obj
452
452
453
- # set using setitem (Panel and > dims)
454
- elif self .ndim >= 3 :
455
- return self .obj .__setitem__ (indexer , value )
456
-
457
453
# set
458
454
item_labels = self .obj ._get_axis (info_axis )
459
455
@@ -642,9 +638,6 @@ def can_do_equal_len():
642
638
elif isinstance (value , ABCDataFrame ):
643
639
value = self ._align_frame (indexer , value )
644
640
645
- if isinstance (value , ABCPanel ):
646
- value = self ._align_panel (indexer , value )
647
-
648
641
# check for chained assignment
649
642
self .obj ._check_is_chained_assignment_possible ()
650
643
@@ -690,7 +683,6 @@ def ravel(i):
690
683
sum_aligners = sum (aligners )
691
684
single_aligner = sum_aligners == 1
692
685
is_frame = self .obj .ndim == 2
693
- is_panel = self .obj .ndim >= 3
694
686
obj = self .obj
695
687
696
688
# are we a single alignable value on a non-primary
@@ -702,11 +694,6 @@ def ravel(i):
702
694
if is_frame :
703
695
single_aligner = single_aligner and aligners [0 ]
704
696
705
- # panel
706
- elif is_panel :
707
- single_aligner = (single_aligner and
708
- (aligners [1 ] or aligners [2 ]))
709
-
710
697
# we have a frame, with multiple indexers on both axes; and a
711
698
# series, so need to broadcast (see GH5206)
712
699
if (sum_aligners == self .ndim and
@@ -738,38 +725,14 @@ def ravel(i):
738
725
return ser .reindex (new_ix )._values
739
726
740
727
# 2 dims
741
- elif single_aligner and is_frame :
728
+ elif single_aligner :
742
729
743
730
# reindex along index
744
731
ax = self .obj .axes [1 ]
745
732
if ser .index .equals (ax ) or not len (ax ):
746
733
return ser ._values .copy ()
747
734
return ser .reindex (ax )._values
748
735
749
- # >2 dims
750
- elif single_aligner :
751
-
752
- broadcast = []
753
- for n , labels in enumerate (self .obj ._get_plane_axes (i )):
754
-
755
- # reindex along the matching dimensions
756
- if len (labels & ser .index ):
757
- ser = ser .reindex (labels )
758
- else :
759
- broadcast .append ((n , len (labels )))
760
-
761
- # broadcast along other dims
762
- ser = ser ._values .copy ()
763
- for (axis , l ) in broadcast :
764
- shape = [- 1 ] * (len (broadcast ) + 1 )
765
- shape [axis ] = l
766
- ser = np .tile (ser , l ).reshape (shape )
767
-
768
- if self .obj .ndim == 3 :
769
- ser = ser .T
770
-
771
- return ser
772
-
773
736
elif is_scalar (indexer ):
774
737
ax = self .obj ._get_axis (1 )
775
738
@@ -782,7 +745,6 @@ def ravel(i):
782
745
783
746
def _align_frame (self , indexer , df ):
784
747
is_frame = self .obj .ndim == 2
785
- is_panel = self .obj .ndim >= 3
786
748
787
749
if isinstance (indexer , tuple ):
788
750
@@ -802,21 +764,6 @@ def _align_frame(self, indexer, df):
802
764
else :
803
765
sindexers .append (i )
804
766
805
- # panel
806
- if is_panel :
807
-
808
- # need to conform to the convention
809
- # as we are not selecting on the items axis
810
- # and we have a single indexer
811
- # GH 7763
812
- if len (sindexers ) == 1 and sindexers [0 ] != 0 :
813
- df = df .T
814
-
815
- if idx is None :
816
- idx = df .index
817
- if cols is None :
818
- cols = df .columns
819
-
820
767
if idx is not None and cols is not None :
821
768
822
769
if df .index .equals (idx ) and df .columns .equals (cols ):
@@ -843,24 +790,8 @@ def _align_frame(self, indexer, df):
843
790
val = df .reindex (index = ax )._values
844
791
return val
845
792
846
- elif is_scalar (indexer ) and is_panel :
847
- idx = self .obj .axes [1 ]
848
- cols = self .obj .axes [2 ]
849
-
850
- # by definition we are indexing on the 0th axis
851
- # a passed in dataframe which is actually a transpose
852
- # of what is needed
853
- if idx .equals (df .index ) and cols .equals (df .columns ):
854
- return df .copy ()._values
855
-
856
- return df .reindex (idx , columns = cols )._values
857
-
858
793
raise ValueError ('Incompatible indexer with DataFrame' )
859
794
860
- def _align_panel (self , indexer , df ):
861
- raise NotImplementedError ("cannot set using an indexer with a Panel "
862
- "yet!" )
863
-
864
795
def _getitem_tuple (self , tup ):
865
796
try :
866
797
return self ._getitem_lowerdim (tup )
@@ -1059,13 +990,6 @@ def _getitem_nested_tuple(self, tup):
1059
990
# has the dim of the obj changed?
1060
991
# GH 7199
1061
992
if obj .ndim < current_ndim :
1062
-
1063
- # GH 7516
1064
- # if had a 3 dim and are going to a 2d
1065
- # axes are reversed on a DataFrame
1066
- if i >= 1 and current_ndim == 3 and obj .ndim == 2 :
1067
- obj = obj .T
1068
-
1069
993
axis -= 1
1070
994
1071
995
return obj
@@ -1562,8 +1486,8 @@ class _LocIndexer(_LocationIndexer):
1562
1486
1563
1487
- A boolean array of the same length as the axis being sliced,
1564
1488
e.g. ``[True, False, True]``.
1565
- - A ``callable`` function with one argument (the calling Series, DataFrame
1566
- or Panel ) and that returns valid output for indexing (one of the above)
1489
+ - A ``callable`` function with one argument (the calling Series or
1490
+ DataFrame ) and that returns valid output for indexing (one of the above)
1567
1491
1568
1492
See more at :ref:`Selection by Label <indexing.label>`
1569
1493
@@ -1931,8 +1855,8 @@ class _iLocIndexer(_LocationIndexer):
1931
1855
- A list or array of integers, e.g. ``[4, 3, 0]``.
1932
1856
- A slice object with ints, e.g. ``1:7``.
1933
1857
- A boolean array.
1934
- - A ``callable`` function with one argument (the calling Series, DataFrame
1935
- or Panel ) and that returns valid output for indexing (one of the above).
1858
+ - A ``callable`` function with one argument (the calling Series or
1859
+ DataFrame ) and that returns valid output for indexing (one of the above).
1936
1860
This is useful in method chains, when you don't have a reference to the
1937
1861
calling object, but would like to base your selection on some value.
1938
1862
0 commit comments