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(str),
...     "probability": pa.Column(float)
... })
>>> print(
...     example_schema.update_column(
...         'category', dtype=pa.Category
...     )
... )
<Schema DataFrameSchema(
    columns={
        'category': <Schema Column(name=category, type=DataType(category))>
        'probability': <Schema Column(name=probability, type=DataType(float64))>
    },
    checks=[],
    coerce=False,
    dtype=None,
    index=None,
    strict=False
    name=None,
    ordered=False
)>

See also

rename_columns()