pandera.schemas.DataFrameSchema.remove_columns

DataFrameSchema.remove_columns(cols_to_remove)[source]

Removes columns from a DataFrameSchema and returns a new copy.

Parameters

cols_to_remove (List) – Columns to be removed from the DataFrameSchema

Return type

DataFrameSchema

Returns

a new DataFrameSchema without the cols_to_remove

Raises

SchemaInitError: if column not in schema.

Example

To remove a column or set of columns from a schema, pass a list of columns to be removed:

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

See also

add_columns()