@@ -2889,11 +2889,11 @@ def _set_value(self, index, col, value, takeable=False):
2889
2889
2890
2890
_set_value .__doc__ = set_value .__doc__
2891
2891
2892
- def _ixs (self , i , axis = 0 ):
2892
+ def _ixs (self , i : int , axis : int = 0 ):
2893
2893
"""
2894
2894
Parameters
2895
2895
----------
2896
- i : int, slice, or sequence of integers
2896
+ i : int
2897
2897
axis : int
2898
2898
2899
2899
Notes
@@ -2902,59 +2902,40 @@ def _ixs(self, i, axis=0):
2902
2902
"""
2903
2903
# irow
2904
2904
if axis == 0 :
2905
- if isinstance (i , slice ):
2906
- return self [i ]
2907
- else :
2908
- label = self .index [i ]
2909
- if isinstance (label , Index ):
2910
- # a location index by definition
2911
- result = self .take (i , axis = axis )
2912
- copy = True
2913
- else :
2914
- new_values = self ._data .fast_xs (i )
2915
- if is_scalar (new_values ):
2916
- return new_values
2917
-
2918
- # if we are a copy, mark as such
2919
- copy = (
2920
- isinstance (new_values , np .ndarray ) and new_values .base is None
2921
- )
2922
- result = self ._constructor_sliced (
2923
- new_values ,
2924
- index = self .columns ,
2925
- name = self .index [i ],
2926
- dtype = new_values .dtype ,
2927
- )
2928
- result ._set_is_copy (self , copy = copy )
2929
- return result
2905
+ label = self .index [i ]
2906
+ new_values = self ._data .fast_xs (i )
2907
+ if is_scalar (new_values ):
2908
+ return new_values
2909
+
2910
+ # if we are a copy, mark as such
2911
+ copy = isinstance (new_values , np .ndarray ) and new_values .base is None
2912
+ result = self ._constructor_sliced (
2913
+ new_values ,
2914
+ index = self .columns ,
2915
+ name = self .index [i ],
2916
+ dtype = new_values .dtype ,
2917
+ )
2918
+ result ._set_is_copy (self , copy = copy )
2919
+ return result
2930
2920
2931
2921
# icol
2932
2922
else :
2933
2923
label = self .columns [i ]
2934
- if isinstance (i , slice ):
2935
- # need to return view
2936
- lab_slice = slice (label [0 ], label [- 1 ])
2937
- return self .loc [:, lab_slice ]
2938
- else :
2939
- if isinstance (label , Index ):
2940
- return self .take (i , axis = 1 )
2941
2924
2942
- index_len = len (self .index )
2925
+ # if the values returned are not the same length
2926
+ # as the index (iow a not found value), iget returns
2927
+ # a 0-len ndarray. This is effectively catching
2928
+ # a numpy error (as numpy should really raise)
2929
+ values = self ._data .iget (i )
2943
2930
2944
- # if the values returned are not the same length
2945
- # as the index (iow a not found value), iget returns
2946
- # a 0-len ndarray. This is effectively catching
2947
- # a numpy error (as numpy should really raise)
2948
- values = self ._data .iget (i )
2931
+ if len (self .index ) and not len (values ):
2932
+ values = np .array ([np .nan ] * len (self .index ), dtype = object )
2933
+ result = self ._box_col_values (values , label )
2949
2934
2950
- if index_len and not len (values ):
2951
- values = np .array ([np .nan ] * index_len , dtype = object )
2952
- result = self ._box_col_values (values , label )
2935
+ # this is a cached value, mark it so
2936
+ result ._set_as_cached (label , self )
2953
2937
2954
- # this is a cached value, mark it so
2955
- result ._set_as_cached (label , self )
2956
-
2957
- return result
2938
+ return result
2958
2939
2959
2940
def __getitem__ (self , key ):
2960
2941
key = lib .item_from_zerodim (key )
0 commit comments