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}}
...     )
... )
<Schema DataFrameSchema(
    columns={
        'category': <Schema Column(name=category, type=category)>
        'probability': <Schema Column(name=probability, type=float)>
    },
    checks=[],
    coerce=False,
    pandas_dtype=None,
    index=None,
    strict=False
    name=None,
    ordered=False
)>

Note

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