Details
-
Bug
-
Status: In Progress
-
Minor
-
Resolution: Unresolved
-
0.17.0
-
None
Description
Generally, pa.array(data).cast(sometype, safe=...) is equivalent to
pa.array(data, sometype, safe=...). Consider the following:
>>> pa.array([Decimal('12.34')]).cast(pa.int32(), safe=False) <pyarrow.lib.Int32Array object at 0x7efbbd1556e0> [ 12 ] >>> pa.array([Decimal('12.34')], pa.int32(), safe=False) <pyarrow.lib.Int32Array object at 0x7efbbd13dad0> [ 12 ]
However, that is not always the case:
>>> pa.array([Decimal('1234')]).cast(pa.int8(), safe=False) <pyarrow.lib.Int8Array object at 0x7efbbd18e4b0> [ -46 ] >>> pa.array([Decimal('1234')], pa.int8(), safe=False) Traceback (most recent call last): ... ArrowInvalid: Value 1234 too large to fit in C integer type
I don't think this is very important: first because you can call cast() directly, second because the results are unusable anyway.
Attachments
Issue Links
- relates to
-
ARROW-16491 [Python] Table.from_pandas is doing unsafe cast for float array to int array
- Open
- links to