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

See also

remove_columns()