@@ -189,18 +189,18 @@ class SimpleDtypeInfo:
189189 "binary[pyarrow]" ,
190190]
191191
192- BOOL_BIGFRAMES_TYPES = [pd . BooleanDtype () ]
192+ BOOL_BIGFRAMES_TYPES = [BOOL_DTYPE ]
193193
194194# Corresponds to the pandas concept of numeric type (such as when 'numeric_only' is specified in an operation)
195195# Pandas is inconsistent, so two definitions are provided, each used in different contexts
196196NUMERIC_BIGFRAMES_TYPES_RESTRICTIVE = [
197- pd . Float64Dtype () ,
198- pd . Int64Dtype () ,
197+ FLOAT_DTYPE ,
198+ INT_DTYPE ,
199199]
200200NUMERIC_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 ,
204204]
205205
206206
@@ -308,10 +308,10 @@ def is_bool_coercable(type_: ExpressionType) -> bool:
308308
309309# special case - string[pyarrow] doesn't include the storage in its name, and both
310310# "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
312312
313313# 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
315315
316316# For the purposes of dataframe.memory_usage
317317DTYPE_BYTE_SIZES = {
@@ -552,14 +552,14 @@ def is_compatible(scalar: typing.Any, dtype: Dtype) -> typing.Optional[Dtype]:
552552 elif pd .api .types .is_numeric_dtype (dtype ):
553553 # Implicit conversion currently only supported for numeric types
554554 if pd .api .types .is_bool (scalar ):
555- return lcd_type (pd . BooleanDtype () , dtype )
555+ return lcd_type (BOOL_DTYPE , dtype )
556556 if pd .api .types .is_float (scalar ):
557- return lcd_type (pd . Float64Dtype () , dtype )
557+ return lcd_type (FLOAT_DTYPE , dtype )
558558 if pd .api .types .is_integer (scalar ):
559- return lcd_type (pd . Int64Dtype () , dtype )
559+ return lcd_type (INT_DTYPE , dtype )
560560 if isinstance (scalar , decimal .Decimal ):
561561 # 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 )
563563 return None
564564
565565
@@ -573,11 +573,11 @@ def lcd_type(*dtypes: Dtype) -> Dtype:
573573 return unique_dtypes .pop ()
574574 # Implicit conversion currently only supported for numeric types
575575 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 ,
581581 ]
582582 if any ([dtype not in hierarchy for dtype in dtypes ]):
583583 return None
0 commit comments