etna.datasets.apply_alignment#
- apply_alignment(df: DataFrame, alignment: Dict[str, Timestamp] | Dict[str, int], original_timestamp_name: str | None = None)[source]#
Apply given alignment to a dataframe.
Applying alignment creates a new dataframe in which we have a new ‘timestamp’ column with sequential integer timestamps.
For each segment we sort timestamps and assign them sequential integer values (with step 1) in a way that timestamp in
alignment
gets value 0.- Parameters:
- Returns:
Aligned dataframe in a long format.
- Raises:
ValueError: – Parameter
df
isn’t in a long format.ValueError: – There is a segment in
df
which isn’t present inalignment
.ValueError: – There is a segment which doesn’t have a timestamp that is present in
alignment
.