Skip to content

Add seasonal_plot #628

Merged
merged 8 commits into from
Apr 1, 2022
Merged

Add seasonal_plot #628

merged 8 commits into from
Apr 1, 2022

Conversation

Mr-Geekman
Copy link
Contributor

@Mr-Geekman Mr-Geekman commented Mar 29, 2022

IMPORTANT: Please do not create a Pull Request without creating an issue first.

Before submitting (must do checklist)

  • Did you read the contribution guide?
  • Did you update the docs? We use Numpy format for all the methods and classes.
  • Did you write any new necessary tests?
  • Did you update the CHANGELOG?

Type of Change

  • Examples / docs / tutorials / contributors update
  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change which improves an existing feature)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Proposed Changes

Look #548.

Related Issue

#548.

Closing issues

Closes #548.

@Mr-Geekman Mr-Geekman added the enhancement New feature or request label Mar 29, 2022
@Mr-Geekman Mr-Geekman self-assigned this Mar 29, 2022
@Mr-Geekman
Copy link
Contributor Author

Example script:

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

from etna.analysis import seasonal_plot
from etna.datasets import TSDataset


def main():
    df = pd.read_csv("examples/data/example_dataset.csv", parse_dates=["timestamp"])
    df_wide = TSDataset.to_dataset(df)
    df_wide.iloc[:10, 0] = np.NaN
    ts = TSDataset(df=df_wide, freq="D")

    # make plot
    seasonal_plot(ts=ts, freq=None, cycle="month")
    plt.savefig("seasonal_plot_day_month")

    seasonal_plot(ts=ts, freq=None, cycle="year")
    plt.savefig("seasonal_plot_day_year")

    seasonal_plot(ts=ts, freq=None, cycle="week", figsize=(10, 10))
    plt.savefig("seasonal_plot_day_week")

    seasonal_plot(ts=ts, freq="W", cycle="year", aggregation="mean")
    plt.savefig("seasonal_plot_week_year_mean")

    seasonal_plot(ts=ts, freq="M", cycle="year", aggregation="sum")
    plt.savefig("seasonal_plot_month_year_sum")

    seasonal_plot(ts=ts, freq=None, cycle=50, alignment="first")
    plt.savefig("seasonal_plot_day_50_first")

    seasonal_plot(ts=ts, freq=None, cycle=50, alignment="last")
    plt.savefig("seasonal_plot_day_50_last")


if __name__ == "__main__":
    main()

seasonal_plot_day_month:
seasonal_plot_day_month

seasonal_plot_day_year:
seasonal_plot_day_year

seasonal_plot_day_week:
seasonal_plot_day_week

seasonal_plot_week_year_mean:
seasonal_plot_week_year_mean

seasonal_plot_month_year_sum:
seasonal_plot_month_year_sum

seasonal_plot_day_50_first:
seasonal_plot_day_50_first

seasonal_plot_day_50_last:
seasonal_plot_day_50_last

@codecov-commenter
Copy link

codecov-commenter commented Mar 29, 2022

Codecov Report

Merging #628 (4dd72e5) into master (ae3095c) will increase coverage by 0.24%.
The diff coverage is 96.72%.

@@            Coverage Diff             @@
##           master     #628      +/-   ##
==========================================
+ Coverage   84.01%   84.26%   +0.24%     
==========================================
  Files         118      118              
  Lines        6120     6242     +122     
==========================================
+ Hits         5142     5260     +118     
- Misses        978      982       +4     
Impacted Files Coverage Δ
etna/analysis/eda_utils.py 48.82% <96.61%> (+31.50%) ⬆️
etna/analysis/__init__.py 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@martins0n martins0n self-requested a review March 30, 2022 07:44
@martins0n
Copy link
Contributor

Yеt another problem with duplicated legend, isn't it?

Copy link
Contributor

@martins0n martins0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯

etna/analysis/eda_utils.py Outdated Show resolved Hide resolved
etna/analysis/eda_utils.py Outdated Show resolved Hide resolved
"""Get number for each point within cycle in a series of timestamps."""
if isinstance(cycle, int):
pass
elif SeasonalPlotCycle(cycle) == SeasonalPlotCycle.hour:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dict with key of type Tuple[SeasonalPlotCycle, str]?

etna/analysis/eda_utils.py Show resolved Hide resolved
tests/test_analysis/test_eda_utils.py Show resolved Hide resolved
Copy link
Contributor

@martins0n martins0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

@martins0n martins0n merged commit c4a71ac into master Apr 1, 2022
@martins0n martins0n deleted the issue-548 branch April 1, 2022 09:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add seasonal plot
3 participants