tseda.report

tseda.report — HTML and console EDA report generation.

Single-call API:

from tseda.report import HTMLReport, ConsoleReport HTMLReport().generate(ts, “report.html”, period=12) ConsoleReport().generate(ts, period=12)

Classes

HTMLReport

Self-contained HTML report with embedded figures.

ConsoleReport

Plain-text EDA summary printed to stdout.

class tseda.report.HTMLReport[source]

Bases: object

Generate a self-contained HTML EDA report.

generate(ts, output_path, period, alpha)[source]

Write the HTML report and return the output path.

Parameters:
Return type:

str

Examples

>>> import numpy as np, pandas as pd, tempfile, os
>>> from tseda import TimeSeries
>>> from tseda.report.html_report import HTMLReport
>>> rng = np.random.default_rng(0)
>>> idx = pd.date_range("2020", periods=100, freq="D")
>>> ts  = TimeSeries(rng.standard_normal(100), index=idx)
>>> with tempfile.NamedTemporaryFile(suffix=".html", delete=False) as f:
...     path = HTMLReport().generate(ts, f.name)
>>> os.path.exists(path)
True
>>> os.unlink(path)
generate(ts, output_path, *, period=None, alpha=0.05)[source]

Generate the HTML EDA report.

Parameters:
  • ts (TimeSeries) – Series to analyse.

  • output_path (str or path-like) – Destination file. Created / overwritten.

  • period (int, optional) – Seasonal period. Auto-detected when None.

  • alpha (float, optional) – Significance level. Default 0.05.

Returns:

Absolute path to the written HTML file.

Return type:

str

Raises:

TypeError – If ts is not a TimeSeries.

class tseda.report.ConsoleReport[source]

Bases: object

Generate a plain-text EDA report for a TimeSeries.

to_string(ts, period, alpha)[source]

Build the report and return it as a string.

Parameters:
Return type:

str

generate(ts, period, alpha)[source]

Print the report to stdout.

Parameters:
Return type:

None

Examples

>>> import numpy as np, pandas as pd
>>> from tseda import TimeSeries
>>> from tseda.report.console_report import ConsoleReport
>>> rng = np.random.default_rng(0)
>>> idx = pd.date_range("2020", periods=100, freq="D")
>>> ts  = TimeSeries(rng.standard_normal(100), index=idx)
>>> s = ConsoleReport().to_string(ts)
>>> isinstance(s, str) and len(s) > 0
True
to_string(ts, *, period=None, alpha=0.05)[source]

Return the full EDA report as a string.

Parameters:
  • ts (TimeSeries)

  • period (int, optional) – Seasonal period. Auto-detected when None.

  • alpha (float, optional) – Significance level for statistical tests. Default 0.05.

Return type:

str

generate(ts, *, period=None, alpha=0.05)[source]

Print the EDA report to stdout.

Parameters:
Return type:

None

Examples

>>> import numpy as np, pandas as pd
>>> from tseda import TimeSeries
>>> from tseda.report.console_report import ConsoleReport
>>> rng = np.random.default_rng(0)
>>> idx = pd.date_range("2020", periods=100, freq="D")
>>> ts  = TimeSeries(rng.standard_normal(100), index=idx)
>>> ConsoleReport().generate(ts)

HTML Report

class tseda.report.html_report.HTMLReport[source]

Bases: object

Generate a self-contained HTML EDA report.

generate(ts, output_path, period, alpha)[source]

Write the HTML report and return the output path.

Parameters:
Return type:

str

Examples

>>> import numpy as np, pandas as pd, tempfile, os
>>> from tseda import TimeSeries
>>> from tseda.report.html_report import HTMLReport
>>> rng = np.random.default_rng(0)
>>> idx = pd.date_range("2020", periods=100, freq="D")
>>> ts  = TimeSeries(rng.standard_normal(100), index=idx)
>>> with tempfile.NamedTemporaryFile(suffix=".html", delete=False) as f:
...     path = HTMLReport().generate(ts, f.name)
>>> os.path.exists(path)
True
>>> os.unlink(path)
generate(ts, output_path, *, period=None, alpha=0.05)[source]

Generate the HTML EDA report.

Parameters:
  • ts (TimeSeries) – Series to analyse.

  • output_path (str or path-like) – Destination file. Created / overwritten.

  • period (int, optional) – Seasonal period. Auto-detected when None.

  • alpha (float, optional) – Significance level. Default 0.05.

Returns:

Absolute path to the written HTML file.

Return type:

str

Raises:

TypeError – If ts is not a TimeSeries.

Console Report

class tseda.report.console_report.ConsoleReport[source]

Bases: object

Generate a plain-text EDA report for a TimeSeries.

to_string(ts, period, alpha)[source]

Build the report and return it as a string.

Parameters:
Return type:

str

generate(ts, period, alpha)[source]

Print the report to stdout.

Parameters:
Return type:

None

Examples

>>> import numpy as np, pandas as pd
>>> from tseda import TimeSeries
>>> from tseda.report.console_report import ConsoleReport
>>> rng = np.random.default_rng(0)
>>> idx = pd.date_range("2020", periods=100, freq="D")
>>> ts  = TimeSeries(rng.standard_normal(100), index=idx)
>>> s = ConsoleReport().to_string(ts)
>>> isinstance(s, str) and len(s) > 0
True
to_string(ts, *, period=None, alpha=0.05)[source]

Return the full EDA report as a string.

Parameters:
  • ts (TimeSeries)

  • period (int, optional) – Seasonal period. Auto-detected when None.

  • alpha (float, optional) – Significance level for statistical tests. Default 0.05.

Return type:

str

generate(ts, *, period=None, alpha=0.05)[source]

Print the EDA report to stdout.

Parameters:
Return type:

None

Examples

>>> import numpy as np, pandas as pd
>>> from tseda import TimeSeries
>>> from tseda.report.console_report import ConsoleReport
>>> rng = np.random.default_rng(0)
>>> idx = pd.date_range("2020", periods=100, freq="D")
>>> ts  = TimeSeries(rng.standard_normal(100), index=idx)
>>> ConsoleReport().generate(ts)