# cudf.Decimal128Dtype#

class cudf.Decimal128Dtype(precision, scale=0)#

Type to represent a decimal128 data.

Parameters:
precisionint

The total number of digits in each value of this dtype

scaleint, optional

The scale of the dtype. See Notes below.

Notes

When the scale is positive:
• numbers with fractional parts (e.g., 0.0042) can be represented

• the scale is the total number of digits to the right of the

decimal point

When the scale is negative:
• only multiples of powers of 10 (including 10**0) can be

represented (e.g., 1729, 4200, 1000000) - the scale represents the number of trailing zeros in the value.

For example, 42 is representable with precision=2 and scale=0. 13.0051 is representable with precision=6 and scale=4, and not representable with precision<6 or scale<4.

Examples

>>> import cudf
>>> decimal128_dtype = cudf.Decimal128Dtype(precision=9, scale=2)
>>> decimal128_dtype
Decimal128Dtype(precision=9, scale=2)

Attributes

 itemsize Length of one column element in bytes. precision The decimal precision, in number of decimal digits (an integer). scale The decimal scale (an integer).

Methods

 from_arrow(typ) Construct a cudf decimal dtype from a pyarrow dtype to_arrow() Return the equivalent pyarrow dtype.
classmethod from_arrow(typ)#

Construct a cudf decimal dtype from a pyarrow dtype

Examples

>>> import cudf
>>> import pyarrow as pa
>>> pa_type = pa.decimal128(precision=9, scale=2)

Constructing a Decimal32Dtype:

>>> cudf.Decimal32Dtype.from_arrow(pa_type)
Decimal64Dtype(precision=9, scale=2)

Constructing a Decimal64Dtype:

>>> cudf.Decimal64Dtype.from_arrow(pa_type)
Decimal64Dtype(precision=9, scale=2)

Constructing a Decimal128Dtype:

>>> cudf.Decimal128Dtype.from_arrow(pa_type)
Decimal128Dtype(precision=9, scale=2)
property itemsize#

Length of one column element in bytes.

property precision#

The decimal precision, in number of decimal digits (an integer).

property scale#

The decimal scale (an integer).

to_arrow()#

Return the equivalent pyarrow dtype.