pandera.schemas.DataFrameSchema.update_columns

DataFrameSchema.update_columns(update_dict)[source]

Create copy of a DataFrameSchema with updated column properties.

Parameters

update_dict (Dict[str, Dict[str, Any]]) –

Return type

DataFrameSchema

Returns

a new DataFrameSchema with updated columns

Raises

SchemaInitError: if column not in schema or you try to change the name.

Example

Calling schema.update_columns returns the DataFrameSchema with the updated columns.

>>> import pandera as pa
>>>
>>> example_schema = pa.DataFrameSchema({
...     "category" : pa.Column(pa.String),
...     "probability": pa.Column(pa.Float)
... })
>>>
>>> print(
...     example_schema.update_columns(
...         {"category": {"pandas_dtype":pa.Category}}
...     )
... )
DataFrameSchema(
    columns={
        "category": "<Schema Column: 'category' type=category>",
        "probability": "<Schema Column: 'probability' type=float>"
    },
    checks=[],
    index=None,
    coerce=False,
    strict=False
)

Note

This is the successor to the update_column method, which will be deprecated.