@@ -72,7 +72,7 @@ def maybe_convert_platform(values):
72
72
return values
73
73
74
74
75
- def is_nested_object (obj ):
75
+ def is_nested_object (obj ) -> bool :
76
76
"""
77
77
return a boolean if we have a nested object, e.g. a Series with 1 or
78
78
more Series elements
@@ -500,11 +500,11 @@ def _ensure_dtype_type(value, dtype):
500
500
501
501
def infer_dtype_from (val , pandas_dtype : bool = False ):
502
502
"""
503
- interpret the dtype from a scalar or array. This is a convenience
504
- routines to infer dtype from a scalar or an array
503
+ Interpret the dtype from a scalar or array.
505
504
506
505
Parameters
507
506
----------
507
+ val : object
508
508
pandas_dtype : bool, default False
509
509
whether to infer dtype including pandas extension types.
510
510
If False, scalar/array belongs to pandas extension types is inferred as
@@ -517,7 +517,7 @@ def infer_dtype_from(val, pandas_dtype: bool = False):
517
517
518
518
def infer_dtype_from_scalar (val , pandas_dtype : bool = False ):
519
519
"""
520
- interpret the dtype from a scalar
520
+ Interpret the dtype from a scalar.
521
521
522
522
Parameters
523
523
----------
@@ -592,7 +592,7 @@ def infer_dtype_from_scalar(val, pandas_dtype: bool = False):
592
592
593
593
def infer_dtype_from_array (arr , pandas_dtype : bool = False ):
594
594
"""
595
- infer the dtype from a scalar or array
595
+ Infer the dtype from a scalar or array.
596
596
597
597
Parameters
598
598
----------
@@ -647,7 +647,8 @@ def infer_dtype_from_array(arr, pandas_dtype: bool = False):
647
647
648
648
649
649
def maybe_infer_dtype_type (element ):
650
- """Try to infer an object's dtype, for use in arithmetic ops
650
+ """
651
+ Try to infer an object's dtype, for use in arithmetic ops.
651
652
652
653
Uses `element.dtype` if that's available.
653
654
Objects implementing the iterator protocol are cast to a NumPy array,
@@ -679,8 +680,9 @@ def maybe_infer_dtype_type(element):
679
680
return tipo
680
681
681
682
682
- def maybe_upcast (values , fill_value = np .nan , dtype = None , copy = False ):
683
- """ provide explicit type promotion and coercion
683
+ def maybe_upcast (values , fill_value = np .nan , dtype = None , copy : bool = False ):
684
+ """
685
+ Provide explicit type promotion and coercion.
684
686
685
687
Parameters
686
688
----------
@@ -759,7 +761,7 @@ def conv(r, dtype):
759
761
return [conv (r , dtype ) for r , dtype in zip (result , dtypes )]
760
762
761
763
762
- def astype_nansafe (arr , dtype , copy = True , skipna = False ):
764
+ def astype_nansafe (arr , dtype , copy : bool = True , skipna : bool = False ):
763
765
"""
764
766
Cast the elements of an array to a given dtype a nan-safe manner.
765
767
@@ -982,7 +984,7 @@ def soft_convert_objects(
982
984
return values
983
985
984
986
985
- def maybe_castable (arr ):
987
+ def maybe_castable (arr ) -> bool :
986
988
# return False to force a non-fastpath
987
989
988
990
# check datetime64[ns]/timedelta64[ns] are valid
@@ -996,7 +998,7 @@ def maybe_castable(arr):
996
998
return arr .dtype .name not in _POSSIBLY_CAST_DTYPES
997
999
998
1000
999
- def maybe_infer_to_datetimelike (value , convert_dates = False ):
1001
+ def maybe_infer_to_datetimelike (value , convert_dates : bool = False ):
1000
1002
"""
1001
1003
we might have a array (or single object) that is datetime like,
1002
1004
and no dtype is passed don't change the value unless we find a
@@ -1103,7 +1105,7 @@ def try_timedelta(v):
1103
1105
return value
1104
1106
1105
1107
1106
- def maybe_cast_to_datetime (value , dtype , errors = "raise" ):
1108
+ def maybe_cast_to_datetime (value , dtype , errors : str = "raise" ):
1107
1109
""" try to cast the array/value to a datetimelike dtype, converting float
1108
1110
nan to iNaT
1109
1111
"""
@@ -1292,7 +1294,7 @@ def find_common_type(types):
1292
1294
1293
1295
def cast_scalar_to_array (shape , value , dtype = None ):
1294
1296
"""
1295
- create np.ndarray of specified shape and dtype, filled with values
1297
+ Create np.ndarray of specified shape and dtype, filled with values.
1296
1298
1297
1299
Parameters
1298
1300
----------
@@ -1318,7 +1320,7 @@ def cast_scalar_to_array(shape, value, dtype=None):
1318
1320
return values
1319
1321
1320
1322
1321
- def construct_1d_arraylike_from_scalar (value , length , dtype ):
1323
+ def construct_1d_arraylike_from_scalar (value , length : int , dtype ):
1322
1324
"""
1323
1325
create a np.ndarray / pandas type of specified shape and dtype
1324
1326
filled with values
@@ -1383,7 +1385,7 @@ def construct_1d_object_array_from_listlike(values):
1383
1385
return result
1384
1386
1385
1387
1386
- def construct_1d_ndarray_preserving_na (values , dtype = None , copy = False ):
1388
+ def construct_1d_ndarray_preserving_na (values , dtype = None , copy : bool = False ):
1387
1389
"""
1388
1390
Construct a new ndarray, coercing `values` to `dtype`, preserving NA.
1389
1391
@@ -1424,7 +1426,7 @@ def construct_1d_ndarray_preserving_na(values, dtype=None, copy=False):
1424
1426
return subarr
1425
1427
1426
1428
1427
- def maybe_cast_to_integer_array (arr , dtype , copy = False ):
1429
+ def maybe_cast_to_integer_array (arr , dtype , copy : bool = False ):
1428
1430
"""
1429
1431
Takes any dtype and returns the casted version, raising for when data is
1430
1432
incompatible with integer/unsigned integer dtypes.
0 commit comments