cudf.core.dtypes.Decimal32Dtype#

class cudf.core.dtypes.Decimal32Dtype(precision, scale=0)#

Type to represent a decimal32 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
>>> decimal32_dtype = cudf.Decimal32Dtype(precision=9, scale=2)
>>> decimal32_dtype
Decimal32Dtype(precision=9, scale=2)

Attributes

precision

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

scale

The decimal scale (an integer).

itemsize

Length of one column element in bytes.

Methods

to_arrow()

Return the equivalent pyarrow dtype.

from_arrow(typ)

Construct a cudf decimal dtype from a pyarrow dtype