Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
We currently allow constructing a decimal array from decimal.Decimal objects or from ints:
In [14]: pa.array([1, 0], type=pa.decimal128(2)) Out[14]: <pyarrow.lib.Decimal128Array object at 0x7f51fa2da818> [ 1, 0 ] In [31]: pa.array([decimal.Decimal('0.1'), decimal.Decimal('0.2')], pa.decimal128(2, 1)) Out[31]: <pyarrow.lib.Decimal128Array object at 0x7fce671172b0> [ 0.1, 0.2 ]
but not from floats (or strings):
In [18]: pa.array([0.1, 0.2], pa.decimal128(2)) ... ArrowTypeError: int or Decimal object expected, got float
Is this something we would like to support?
There are for sure precision issues you run into, but if the decimal type is fully specified, it seems clear what the user wants. In general, since decimal objects in pandas are not that easy to work with, many people might have plain float columns that they want to convert to decimal.
Attachments
Issue Links
- is related to
-
ARROW-7011 [C++] Implement casts from float/double to decimal128
- Resolved
- relates to
-
ARROW-7010 [C++] Support lossy casts from decimal128 to float32 and float64/double
- Resolved