pandera.engines.narwhals_engine.Engine

class pandera.engines.narwhals_engine.Engine[source]

Narwhals data type engine.

Methods

classmethod dtype(data_type)[source]

Convert input into a Narwhals-compatible Pandera DataType object.

If data_type is an engine-specific dtype from another backend (e.g. polars_engine.Int64), the method falls back to the shared abstract pandera base class (e.g. dtypes.Int64) so cross-engine dtype comparisons work without importing the foreign engine.

Parametrized narwhals native instances (e.g. nw.Datetime("us")) are dispatched through their from_parametrized_dtype handler so their parameters (time_unit, time_zone) are preserved; the base get_equivalent fast-path would otherwise collapse them onto the un-parametrized dtype (a nw.Datetime instance compares equal to the nw.Datetime class, so the equivalents lookup shadows the parametrized form).

Return type:

DataType