I need to check a data frame for joint uniqueness of similar columns. In the documentation I have found this code snippet but it is applicable only to DataFrameSchema.
import pandas as pd
import pandera as pa
schema = pa.DataFrameSchema(
columns={col: pa.Column(int) for col in ["a", "b", "c"]},
unique=["a", "c"],
report_duplicates = "exclude_first",
)
df = pd.DataFrame.from_records([
{"a": 1, "b": 2, "c": 3},
{"a": 1, "b": 2, "c": 3},
])
schema.validate(df)
null_schema = DataFrameSchema({
"column1": Column(float, Check(lambda x: x > 0), nullable=True)
})
print(null_schema.validate(df))
How would I implement that for a SchemaModel other than resorting to data frame wide schema checks?
Is there a Field configuration for lambda checks at field level similar to this?
null_schema = DataFrameSchema({
"column1": Column(float, Check(lambda x: x > 0), nullable=True)
})
print(null_schema.validate(df))