etna-team / etna

ETNA – Time-Series Library
https://etna.tinkoff.ru
Apache License 2.0
112 stars 6 forks source link

Fix `plot_time_series_with_change_points` to work with NaNs in the middle #11

Open Mr-Geekman opened 1 year ago

Mr-Geekman commented 1 year ago

Issue by alex-hse-repository Thursday Jun 02, 2022 at 15:46 GMT Originally opened as https://github.com/tinkoff-ai/etna/issues/729


🚀 Feature Request

Fixes for EDA methods.

Proposal

Function plot_time_series_with_change_points does not work with NaNs in the middle of the series, try to fix it somehow or throw the appropriate exception.

Test cases

TODO

Additional context

As a result of decomposition two more tasks were created:

d-a-bunin commented 3 months ago

I can' reproduce an error, it works fine:

import numpy as np

import matplotlib.pyplot as plt

from etna.analysis import plot_time_series_with_change_points
from etna.datasets import TSDataset, generate_ar_df

def main():
    df = generate_ar_df(periods=30, n_segments=3, start_time="2020-01-01", freq="D")
    df.loc[df.index[5:7], "target"] = np.NaN
    ts = TSDataset(df=df, freq="D")

    change_points = {
        "segment_0": [ts.index[10]],
        "segment_1": [ts.index[17]],
        "segment_2": [],
    }
    plot_time_series_with_change_points(ts=ts, change_points=change_points)

    plt.savefig("plot_time_series_with_change_points.png", bbox_inches="tight")

if __name__ == "__main__":
    main()