@@ -214,8 +214,7 @@ def __getitem__(self, item):
214
214
"""
215
215
raise AbstractMethodError (self )
216
216
217
- def __setitem__ (self , key , value ):
218
- # type: (Union[int, np.ndarray], Any) -> None
217
+ def __setitem__ (self , key : Union [int , np .ndarray ], value : Any ) -> None :
219
218
"""
220
219
Set one or more values inplace.
221
220
@@ -262,8 +261,7 @@ def __setitem__(self, key, value):
262
261
type (self ), '__setitem__' )
263
262
)
264
263
265
- def __len__ (self ):
266
- # type: () -> int
264
+ def __len__ (self ) -> int :
267
265
"""
268
266
Length of this array
269
267
@@ -287,32 +285,28 @@ def __iter__(self):
287
285
# Required attributes
288
286
# ------------------------------------------------------------------------
289
287
@property
290
- def dtype (self ):
291
- # type: () -> ExtensionDtype
288
+ def dtype (self ) -> ExtensionDtype :
292
289
"""
293
290
An instance of 'ExtensionDtype'.
294
291
"""
295
292
raise AbstractMethodError (self )
296
293
297
294
@property
298
- def shape (self ):
299
- # type: () -> Tuple[int, ...]
295
+ def shape (self ) -> Tuple [int , ...]:
300
296
"""
301
297
Return a tuple of the array dimensions.
302
298
"""
303
299
return (len (self ),)
304
300
305
301
@property
306
- def ndim (self ):
307
- # type: () -> int
302
+ def ndim (self ) -> int :
308
303
"""
309
304
Extension Arrays are only allowed to be 1-dimensional.
310
305
"""
311
306
return 1
312
307
313
308
@property
314
- def nbytes (self ):
315
- # type: () -> int
309
+ def nbytes (self ) -> int :
316
310
"""
317
311
The number of bytes needed to store this object in memory.
318
312
"""
@@ -343,8 +337,7 @@ def astype(self, dtype, copy=True):
343
337
"""
344
338
return np .array (self , dtype = dtype , copy = copy )
345
339
346
- def isna (self ):
347
- # type: () -> Union[ExtensionArray, np.ndarray]
340
+ def isna (self ) -> Union ['ExtensionArray' , np .ndarray ]:
348
341
"""
349
342
A 1-D array indicating if each value is missing.
350
343
@@ -366,8 +359,7 @@ def isna(self):
366
359
"""
367
360
raise AbstractMethodError (self )
368
361
369
- def _values_for_argsort (self ):
370
- # type: () -> np.ndarray
362
+ def _values_for_argsort (self ) -> np .ndarray :
371
363
"""
372
364
Return values for sorting.
373
365
@@ -482,8 +474,11 @@ def dropna(self):
482
474
"""
483
475
return self [~ self .isna ()]
484
476
485
- def shift (self , periods = 1 , fill_value = None ):
486
- # type: (int, object) -> ExtensionArray
477
+ def shift (
478
+ self ,
479
+ periods : int = 1 ,
480
+ fill_value : object = None ,
481
+ ) -> 'ExtensionArray' :
487
482
"""
488
483
Shift values by desired number.
489
484
@@ -598,8 +593,7 @@ def searchsorted(self, value, side="left", sorter=None):
598
593
arr = self .astype (object )
599
594
return arr .searchsorted (value , side = side , sorter = sorter )
600
595
601
- def _values_for_factorize (self ):
602
- # type: () -> Tuple[np.ndarray, Any]
596
+ def _values_for_factorize (self ) -> Tuple [np .ndarray , Any ]:
603
597
"""
604
598
Return an array and missing value suitable for factorization.
605
599
@@ -623,8 +617,10 @@ def _values_for_factorize(self):
623
617
"""
624
618
return self .astype (object ), np .nan
625
619
626
- def factorize (self , na_sentinel = - 1 ):
627
- # type: (int) -> Tuple[np.ndarray, ExtensionArray]
620
+ def factorize (
621
+ self ,
622
+ na_sentinel : int = - 1 ,
623
+ ) -> Tuple [np .ndarray , 'ExtensionArray' ]:
628
624
"""
629
625
Encode the extension array as an enumerated type.
630
626
@@ -726,8 +722,12 @@ def repeat(self, repeats, axis=None):
726
722
# Indexing methods
727
723
# ------------------------------------------------------------------------
728
724
729
- def take (self , indices , allow_fill = False , fill_value = None ):
730
- # type: (Sequence[int], bool, Optional[Any]) -> ExtensionArray
725
+ def take (
726
+ self ,
727
+ indices : Sequence [int ],
728
+ allow_fill : bool = False ,
729
+ fill_value : Optional [Any ] = None
730
+ ) -> 'ExtensionArray' :
731
731
"""
732
732
Take elements from an array.
733
733
@@ -816,8 +816,7 @@ def take(self, indices, allow_fill=False, fill_value=None):
816
816
# pandas.api.extensions.take
817
817
raise AbstractMethodError (self )
818
818
819
- def copy (self , deep = False ):
820
- # type: (bool) -> ExtensionArray
819
+ def copy (self , deep : bool = False ) -> 'ExtensionArray' :
821
820
"""
822
821
Return a copy of the array.
823
822
@@ -853,8 +852,10 @@ def __repr__(self):
853
852
length = len (self ),
854
853
dtype = self .dtype )
855
854
856
- def _formatter (self , boxed = False ):
857
- # type: (bool) -> Callable[[Any], Optional[str]]
855
+ def _formatter (
856
+ self ,
857
+ boxed : bool = False ,
858
+ ) -> Callable [[Any ], Optional [str ]]:
858
859
"""Formatting function for scalar values.
859
860
860
861
This is used in the default '__repr__'. The returned formatting
@@ -881,8 +882,7 @@ def _formatter(self, boxed=False):
881
882
return str
882
883
return repr
883
884
884
- def _formatting_values (self ):
885
- # type: () -> np.ndarray
885
+ def _formatting_values (self ) -> np .ndarray :
886
886
# At the moment, this has to be an array since we use result.dtype
887
887
"""
888
888
An array of values to be printed in, e.g. the Series repr
@@ -898,8 +898,10 @@ def _formatting_values(self):
898
898
# ------------------------------------------------------------------------
899
899
900
900
@classmethod
901
- def _concat_same_type (cls , to_concat ):
902
- # type: (Sequence[ExtensionArray]) -> ExtensionArray
901
+ def _concat_same_type (
902
+ cls ,
903
+ to_concat : Sequence ['ExtensionArray' ]
904
+ ) -> 'ExtensionArray' :
903
905
"""
904
906
Concatenate multiple array
905
907
@@ -921,8 +923,7 @@ def _concat_same_type(cls, to_concat):
921
923
_can_hold_na = True
922
924
923
925
@property
924
- def _ndarray_values (self ):
925
- # type: () -> np.ndarray
926
+ def _ndarray_values (self ) -> np .ndarray :
926
927
"""
927
928
Internal pandas method for lossy conversion to a NumPy ndarray.
928
929
0 commit comments