@@ -189,18 +189,18 @@ class SimpleDtypeInfo:
189
189
"binary[pyarrow]" ,
190
190
]
191
191
192
- BOOL_BIGFRAMES_TYPES = [pd . BooleanDtype () ]
192
+ BOOL_BIGFRAMES_TYPES = [BOOL_DTYPE ]
193
193
194
194
# Corresponds to the pandas concept of numeric type (such as when 'numeric_only' is specified in an operation)
195
195
# Pandas is inconsistent, so two definitions are provided, each used in different contexts
196
196
NUMERIC_BIGFRAMES_TYPES_RESTRICTIVE = [
197
- pd . Float64Dtype () ,
198
- pd . Int64Dtype () ,
197
+ FLOAT_DTYPE ,
198
+ INT_DTYPE ,
199
199
]
200
200
NUMERIC_BIGFRAMES_TYPES_PERMISSIVE = NUMERIC_BIGFRAMES_TYPES_RESTRICTIVE + [
201
- pd . BooleanDtype () ,
202
- pd . ArrowDtype ( pa . decimal128 ( 38 , 9 )) ,
203
- pd . ArrowDtype ( pa . decimal256 ( 76 , 38 )) ,
201
+ BOOL_DTYPE ,
202
+ NUMERIC_DTYPE ,
203
+ BIGNUMERIC_DTYPE ,
204
204
]
205
205
206
206
@@ -308,10 +308,10 @@ def is_bool_coercable(type_: ExpressionType) -> bool:
308
308
309
309
# special case - string[pyarrow] doesn't include the storage in its name, and both
310
310
# "string" and "string[pyarrow]" are accepted
311
- BIGFRAMES_STRING_TO_BIGFRAMES ["string[pyarrow]" ] = pd . StringDtype ( storage = "pyarrow" )
311
+ BIGFRAMES_STRING_TO_BIGFRAMES ["string[pyarrow]" ] = STRING_DTYPE
312
312
313
313
# special case - both "Int64" and "int64[pyarrow]" are accepted
314
- BIGFRAMES_STRING_TO_BIGFRAMES ["int64[pyarrow]" ] = pd . Int64Dtype ()
314
+ BIGFRAMES_STRING_TO_BIGFRAMES ["int64[pyarrow]" ] = INT_DTYPE
315
315
316
316
# For the purposes of dataframe.memory_usage
317
317
DTYPE_BYTE_SIZES = {
@@ -552,14 +552,14 @@ def is_compatible(scalar: typing.Any, dtype: Dtype) -> typing.Optional[Dtype]:
552
552
elif pd .api .types .is_numeric_dtype (dtype ):
553
553
# Implicit conversion currently only supported for numeric types
554
554
if pd .api .types .is_bool (scalar ):
555
- return lcd_type (pd . BooleanDtype () , dtype )
555
+ return lcd_type (BOOL_DTYPE , dtype )
556
556
if pd .api .types .is_float (scalar ):
557
- return lcd_type (pd . Float64Dtype () , dtype )
557
+ return lcd_type (FLOAT_DTYPE , dtype )
558
558
if pd .api .types .is_integer (scalar ):
559
- return lcd_type (pd . Int64Dtype () , dtype )
559
+ return lcd_type (INT_DTYPE , dtype )
560
560
if isinstance (scalar , decimal .Decimal ):
561
561
# TODO: Check context to see if can use NUMERIC instead of BIGNUMERIC
562
- return lcd_type (pd . ArrowDtype ( pa . decimal256 ( 76 , 38 )) , dtype )
562
+ return lcd_type (BIGNUMERIC_DTYPE , dtype )
563
563
return None
564
564
565
565
@@ -573,11 +573,11 @@ def lcd_type(*dtypes: Dtype) -> Dtype:
573
573
return unique_dtypes .pop ()
574
574
# Implicit conversion currently only supported for numeric types
575
575
hierarchy : list [Dtype ] = [
576
- pd . BooleanDtype () ,
577
- pd . Int64Dtype () ,
578
- pd . ArrowDtype ( pa . decimal128 ( 38 , 9 )) ,
579
- pd . ArrowDtype ( pa . decimal256 ( 76 , 38 )) ,
580
- pd . Float64Dtype () ,
576
+ BOOL_DTYPE ,
577
+ INT_DTYPE ,
578
+ NUMERIC_DTYPE ,
579
+ BIGNUMERIC_DTYPE ,
580
+ FLOAT_DTYPE ,
581
581
]
582
582
if any ([dtype not in hierarchy for dtype in dtypes ]):
583
583
return None
0 commit comments