I have a dataframe with a column "Period" which should have a dtype of pandas.Period.
I would like to validate this, using a Pandera Schema (either DataFrameModel or DataFrameSchema).
My attempts so far return errors.
If I try the code below, then I get an error
Data type '<class 'pandas._libs.tslibs.period.Period'>' not understood by Engine.
Code:
import pandas as pd
import pandera as pa
from pandera.typing import Series
class Schema(pa.DataFrameModel):
period: Series[pd.Period]
df = pd.DataFrame({"period" : pd.period_range("31/01/2024", "31/12/2024", freq='M')})
Schema.validate(df)
Any advice is much appreciated!