@@ -904,33 +904,26 @@ def iset(self, loc: Union[int, slice, np.ndarray], value):
904
904
self .arrays [mgr_idx ] = value_arr
905
905
return
906
906
907
- def insert (self , loc : int , item : Hashable , value , allow_duplicates : bool = False ) :
907
+ def insert (self , loc : int , item : Hashable , value : ArrayLike ) -> None :
908
908
"""
909
909
Insert item at selected position.
910
910
911
911
Parameters
912
912
----------
913
913
loc : int
914
914
item : hashable
915
- value : array_like
916
- allow_duplicates: bool
917
- If False, trying to insert non-unique item will raise
918
-
915
+ value : np.ndarray or ExtensionArray
919
916
"""
920
- if not allow_duplicates and item in self .items :
921
- # Should this be a different kind of error??
922
- raise ValueError (f"cannot insert { item } , already exists" )
923
-
924
- if not isinstance (loc , int ):
925
- raise TypeError ("loc must be int" )
926
-
927
917
# insert to the axis; this could possibly raise a TypeError
928
918
new_axis = self .items .insert (loc , item )
929
919
930
920
value = extract_array (value , extract_numpy = True )
931
921
if value .ndim == 2 :
932
922
if value .shape [0 ] == 1 :
933
- value = value [0 , :]
923
+ # error: Invalid index type "Tuple[int, slice]" for
924
+ # "Union[Any, ExtensionArray, ndarray]"; expected type
925
+ # "Union[int, slice, ndarray]"
926
+ value = value [0 , :] # type: ignore[index]
934
927
else :
935
928
raise ValueError (
936
929
f"Expected a 1D array, got an array with shape { value .shape } "
0 commit comments