pandera.engines.pandas_engine.Decimal

class pandera.engines.pandas_engine.Decimal(precision=28, scale=0, rounding=None)[source]

Semantic representation of a decimal.Decimal.

Note

decimal.Decimal is especially useful when exporting a pandas DataFrame to parquet files via pyarrow. Pyarrow will automatically convert the decimal objects contained in the object series to the corresponding parquet Decimal type.

Attributes

auto_coerce

Whether to force coerce to be True in all cases

continuous

Whether the number data type is continuous.

exact

Whether the data type is an exact representation of a number.

precision

The number of significant digits that the decimal type can represent.

scale

The number of digits after the decimal point.

type

Native pandas dtype boxed by the data type.

rounding

The rounding mode supported by the Python decimal.Decimal class.

Methods

__init__(precision=28, scale=0, rounding=None)[source]
check(pandera_dtype, data_container=None)[source]

Check that pandera DataType are equivalent.

Parameters:
  • pandera_dtype (DataType) – Expected DataType.

  • data_container (UnionType[Series, None]) – Data container, used by data types that require the actual data for validation.

Return type:

Union[bool, Iterable[bool]]

Returns:

boolean scalar or iterable of boolean scalars, indicating which elements passed the check.

coerce(data_container)[source]

Pure coerce without catching exceptions.

Return type:

Union[Series, DataFrame]

coerce_value(value)[source]

Coerce a value to a particular type.

Return type:

Decimal

try_coerce(data_container)[source]

Coerce data container to the data type, raises a ParserError if the coercion fails :raises: ParserError: if coercion fails

Return type:

Union[Series, DataFrame]

__call__(data_container)[source]

Coerce data container to the data type.