| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/generated/../api/../api/../generated/pyarrow.decimal128.html | [Back] [Original] |
Section Navigation
Create decimal type with precision and scale and 128-bit width.
Arrow decimals are fixed-point decimal numbers encoded as a scaled integer. The precision is the number of significant digits that the decimal type can represent; the scale is the number of digits after the decimal point (note the scale can be negative).
As an example, decimal128(7, 3) can exactly represent the numbers
1234.567 and -1234.567 (encoded internally as the 128-bit integers
1234567 and -1234567, respectively), but neither 12345.67 nor 123.4567.
decimal128(5, -3) can exactly represent the number 12345000
(encoded internally as the 128-bit integer 12345), but neither
123450000 nor 1234500.
If you need a precision higher than 38 significant digits, consider
using decimal256.
Decimal128TypeExamples
Create an instance of decimal type:
>>> import pyarrow as pa
>>> pa.decimal128(5, 2)
Decimal128Type(decimal128(5, 2))
Create an array with decimal type:
>>> import decimal
>>> a = decimal.Decimal('123.45')
>>> pa.array([a], pa.decimal128(5, 2))
<pyarrow.lib.Decimal128Array object at ...>
[
123.45
]
Copyright 2016-2026 Apache Software Foundation.
Apache Arrow, Arrow, Apache, the Apache logo, and the Apache Arrow project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
Created using Sphinx 9.1.0.
Built with the PyData Sphinx Theme 0.20.0.
| Web Proxy Viewer | New URL | Original Page |