importpyarrowaspaimportpandasaspdimportdecimalpa.Table.from_pandas(pd.DataFrame({'a': [decimal.Decimal('1.1'), decimal.Decimal('2E+1')]}))Traceback (mostrecentcalllast):
File"<stdin>", line1, in <module>
File"pyarrow/table.pxi", line875, inpyarrow.lib.Table.from_pandas (/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx:44927)
File"/home/skadlec/.local/lib/python3.6/site-packages/pyarrow/pandas_compat.py", line350, indataframe_to_arraysconvert_types)]
File"/home/skadlec/.local/lib/python3.6/site-packages/pyarrow/pandas_compat.py", line349, in <listcomp>
forc, tinzip(columns_to_convert,
File"/home/skadlec/.local/lib/python3.6/site-packages/pyarrow/pandas_compat.py", line345, inconvert_columnreturnpa.array(col, from_pandas=True, type=ty)
File"pyarrow/array.pxi", line170, inpyarrow.lib.array (/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx:29224)
File"pyarrow/array.pxi", line70, inpyarrow.lib._ndarray_to_array (/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx:28465)
File"pyarrow/error.pxi", line77, inpyarrow.lib.check_status (/arrow/python/build/temp.linux-x86_64-3.6/lib.cxx:8270)
pyarrow.lib.ArrowInvalid: Expectedbasetendigitordecimalpointbutfound'E'instead.
In manual cases clearly we can write decimal.Decimal('20') instead of decimal.Decimal('2E+1') but during arithmetical operations inside an application the exponential notation can be produced out of control (it is actually the normalized form of the decimal number) plus for some values the exponential notation is the only form expressing the significance so this should be accepted.
The documentation suggests using following transformation but that's only possible when the significance information doesn't need to be kept:
defremove_exponent(d):
returnd.quantize(Decimal(1)) ifd == d.to_integral() elsed.normalize()
Reporter: Antony Mayi / @antonymayi
Assignee: Phillip Cloud / @cpcloud
Related issues:
PRs and other links:
Note: This issue was originally created as ARROW-2153. Please see the migration documentation for further details.
In manual cases clearly we can write
decimal.Decimal('20')instead ofdecimal.Decimal('2E+1')but during arithmetical operations inside an application the exponential notation can be produced out of control (it is actually the normalized form of the decimal number) plus for some values the exponential notation is the only form expressing the significance so this should be accepted.The documentation suggests using following transformation but that's only possible when the significance information doesn't need to be kept:
Reporter: Antony Mayi / @antonymayi
Assignee: Phillip Cloud / @cpcloud
Related issues:
PRs and other links:
Note: This issue was originally created as ARROW-2153. Please see the migration documentation for further details.