causalis.data_contracts.panel_data_scm¶
Module Contents¶
Classes¶
Validated long-format panel contract for Synthetic Control estimators. |
Data¶
API¶
- causalis.data_contracts.panel_data_scm.TimeLike¶
None
- class causalis.data_contracts.panel_data_scm.PanelDataSCM(/, **data: Any)¶
Bases:
pydantic.BaseModelValidated long-format panel contract for Synthetic Control estimators.
Required fields
df : pandas.DataFrame Long-format panel data. y : str Outcome column name in
df. unit_col : str Unit identifier column name indf. time_col : str Calendar time column name indf. Preferred input format ispandas.Periodvalues with a regular frequency (for example monthlyPeriod['M']). Datetime/string values are accepted only when a regular frequency can be inferred. treated_time : str Binary treatment-assignment column indf(0/1 or False/True).Notes
There are no optional contract fields. Extra keyword arguments are rejected. The contract derives
treated_unit,treatment_start, andtime_freqfrom the input data. The model stores a validated internal dataframe snapshot used by all contract methods; mutating the publicdfattribute after construction does not affect validated contract behavior. Outcomeymust not contain null/NaN values. Represent missing panel periods by omitting unit-time rows, not by keeping rows withNaNoutcome. For fiscal quarter/year semantics, passtime_colexplicitly aspandas.Periodwith the desired fiscal frequency.Initialization
Create a new model by parsing and validating input data from keyword arguments.
Raises [
ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.selfis explicitly positional-only to allowselfas a field name.- model_config¶
‘ConfigDict(…)’
- df: pandas.DataFrame¶
‘Field(…)’
- y: str¶
‘Field(…)’
- unit_col: str¶
‘Field(…)’
- time_col: str¶
‘Field(…)’
- treated_time: str¶
‘Field(…)’
- property treated_unit: Hashable¶
- property treatment_start: pandas.Period¶
- property time_freq: str¶
- property n_pre_periods: int¶
- property n_post_periods: int¶
- property last_post_period: pandas.Period¶
- donor_pool() Sequence[Hashable]¶
- df_analysis() pandas.DataFrame¶
- pre_times() Sequence[pandas.Period]¶
- post_times() Sequence[pandas.Period]¶
- analysis_times() Sequence[pandas.Period]¶
- time_to_index() dict[pandas.Period, int]¶
- treatment_start_idx() int¶
- __repr__() str¶