pandera.schemas.DataFrameSchema.add_columns

DataFrameSchema.add_columns(extra_schema_cols)[source]

Create a copy of the DataFrameSchema with extra columns.

Parameters

extra_schema_cols (DataFrameSchema) – Additional columns of the format

Return type

DataFrameSchema

Returns

a new DataFrameSchema with the extra_schema_cols added.

Example

To add columns to the schema, pass a dictionary with column name and Column instance key-value pairs.

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

See also

remove_columns()