173
173
174
174
_unsortable_types = frozenset (("mixed" , "mixed-integer" ))
175
175
176
- _index_doc_kwargs = {
176
+ _index_doc_kwargs : dict [ str , str ] = {
177
177
"klass" : "Index" ,
178
178
"inplace" : "" ,
179
179
"target_klass" : "Index" ,
180
180
"raises_section" : "" ,
181
181
"unique" : "Index" ,
182
182
"duplicated" : "np.ndarray" ,
183
183
}
184
- _index_shared_docs = {}
184
+ _index_shared_docs : dict [ str , str ] = {}
185
185
str_t = str
186
186
187
187
@@ -1189,7 +1189,7 @@ def _format_with_header(
1189
1189
return header + result
1190
1190
1191
1191
@final
1192
- def to_native_types (self , slicer = None , ** kwargs ):
1192
+ def to_native_types (self , slicer = None , ** kwargs ) -> np . ndarray :
1193
1193
"""
1194
1194
Format specified values of `self` and return them.
1195
1195
@@ -4388,7 +4388,7 @@ def memory_usage(self, deep: bool = False) -> int:
4388
4388
return result
4389
4389
4390
4390
@final
4391
- def where (self , cond , other = None ):
4391
+ def where (self , cond , other = None ) -> Index :
4392
4392
"""
4393
4393
Replace values where the condition is False.
4394
4394
@@ -4604,7 +4604,7 @@ def _can_hold_identifiers_and_holds_name(self, name) -> bool:
4604
4604
return name in self
4605
4605
return False
4606
4606
4607
- def append (self , other ):
4607
+ def append (self , other ) -> Index :
4608
4608
"""
4609
4609
Append a collection of Index options together.
4610
4610
@@ -4614,7 +4614,7 @@ def append(self, other):
4614
4614
4615
4615
Returns
4616
4616
-------
4617
- appended : Index
4617
+ Index
4618
4618
"""
4619
4619
to_concat = [self ]
4620
4620
@@ -4844,7 +4844,7 @@ def asof(self, label):
4844
4844
loc = loc .indices (len (self ))[- 1 ]
4845
4845
return self [loc ]
4846
4846
4847
- def asof_locs (self , where : Index , mask ) -> np .ndarray :
4847
+ def asof_locs (self , where : Index , mask : np . ndarray ) -> np .ndarray :
4848
4848
"""
4849
4849
Return the locations (indices) of labels in the index.
4850
4850
@@ -4861,21 +4861,21 @@ def asof_locs(self, where: Index, mask) -> np.ndarray:
4861
4861
----------
4862
4862
where : Index
4863
4863
An Index consisting of an array of timestamps.
4864
- mask : array-like
4864
+ mask : np.ndarray[bool]
4865
4865
Array of booleans denoting where values in the original
4866
4866
data are not NA.
4867
4867
4868
4868
Returns
4869
4869
-------
4870
- numpy .ndarray
4870
+ np .ndarray[np.intp]
4871
4871
An array of locations (indices) of the labels from the Index
4872
4872
which correspond to the return values of the `asof` function
4873
4873
for every element in `where`.
4874
4874
"""
4875
4875
locs = self ._values [mask ].searchsorted (where ._values , side = "right" )
4876
4876
locs = np .where (locs > 0 , locs - 1 , 0 )
4877
4877
4878
- result = np .arange (len (self ))[mask ].take (locs )
4878
+ result = np .arange (len (self ), dtype = np . intp )[mask ].take (locs )
4879
4879
4880
4880
# TODO: overload return type of ExtensionArray.__getitem__
4881
4881
first_value = cast (Any , self ._values [mask .argmax ()])
@@ -5048,7 +5048,7 @@ def argsort(self, *args, **kwargs) -> np.ndarray:
5048
5048
5049
5049
Returns
5050
5050
-------
5051
- numpy .ndarray
5051
+ np .ndarray[np.intp]
5052
5052
Integer indices that would sort the index if used as
5053
5053
an indexer.
5054
5054
@@ -5836,7 +5836,7 @@ def delete(self, loc) -> Index:
5836
5836
Returns
5837
5837
-------
5838
5838
Index
5839
- New Index with passed location(-s) deleted .
5839
+ Will be same type as self, except for RangeIndex .
5840
5840
5841
5841
See Also
5842
5842
--------
@@ -6350,8 +6350,8 @@ def _maybe_cast_data_without_dtype(subarr):
6350
6350
6351
6351
elif inferred == "interval" :
6352
6352
try :
6353
- data = IntervalArray ._from_sequence (subarr , copy = False )
6354
- return data
6353
+ ia_data = IntervalArray ._from_sequence (subarr , copy = False )
6354
+ return ia_data
6355
6355
except (ValueError , TypeError ):
6356
6356
# GH27172: mixed closed Intervals --> object dtype
6357
6357
pass
0 commit comments