pandera.schemas.DataFrameSchema.update_column

DataFrameSchema.update_column(column_name, **kwargs)[source]

Create copy of a DataFrameSchema with updated column properties.

Parameters
  • column_name (str) –

  • kwargs – key-word arguments supplied to Column

Return type

DataFrameSchema

Returns

a new DataFrameSchema with updated column

Raises

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

Example

Calling schema.1 returns the DataFrameSchema with the updated column.

>>> import pandera as pa
>>>
>>> example_schema = pa.DataFrameSchema({
...     "category" : pa.Column(pa.String),
...     "probability": pa.Column(pa.Float)
... })
>>> print(
...     example_schema.update_column(
...         '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
)>

See also

rename_columns()