Skip to content

arkas.content

arkas.content

Contain HTML content generators.

arkas.content.AccuracyContentGenerator

Bases: BaseSectionContentGenerator

Implement a HTML content generator that analyzes accuracy performances.

Parameters:

Name Type Description Default
evaluator AccuracyEvaluator

The evaluator object to compute the accuracy.

required

Example usage:

>>> import numpy as np
>>> from arkas.content import AccuracyContentGenerator
>>> from arkas.evaluator2 import AccuracyEvaluator
>>> from arkas.state import AccuracyState
>>> content = AccuracyContentGenerator(
...     AccuracyEvaluator(
...         AccuracyState(
...             y_true=np.array([1, 0, 0, 1, 1]),
...             y_pred=np.array([1, 0, 0, 1, 1]),
...             y_true_name="target",
...             y_pred_name="pred",
...         )
...     )
... )
>>> content
AccuracyContentGenerator(
  (evaluator): AccuracyEvaluator(
      (state): AccuracyState(y_true=(5,), y_pred=(5,), y_true_name='target', y_pred_name='pred', nan_policy='propagate')
    )
)
arkas.content.AccuracyContentGenerator.from_state classmethod
from_state(
    state: AccuracyState,
) -> AccuracyContentGenerator

Instantiate a AccuracyContentGenerator object from a state.

Parameters:

Name Type Description Default
state AccuracyState

The state with the data to analyze.

required

Returns:

Type Description
AccuracyContentGenerator

The instantiated object.

Example usage:

>>> import numpy as np
>>> from arkas.content import AccuracyContentGenerator
>>> from arkas.state import AccuracyState
>>> content = AccuracyContentGenerator.from_state(
...     AccuracyState(
...         y_true=np.array([1, 0, 0, 1, 1]),
...         y_pred=np.array([1, 0, 0, 1, 1]),
...         y_true_name="target",
...         y_pred_name="pred",
...     )
... )
>>> content
AccuracyContentGenerator(
  (evaluator): AccuracyEvaluator(
      (state): AccuracyState(y_true=(5,), y_pred=(5,), y_true_name='target', y_pred_name='pred', nan_policy='propagate')
    )
)

arkas.content.BalancedAccuracyContentGenerator

Bases: BaseSectionContentGenerator

Implement a HTML content generator that analyzes balanced accuracy performances.

Parameters:

Name Type Description Default
evaluator BalancedAccuracyEvaluator

The evaluator object to compute the balanced accuracy.

required

Example usage:

>>> import numpy as np
>>> from arkas.content import BalancedAccuracyContentGenerator
>>> from arkas.state import AccuracyState
>>> generator = BalancedAccuracyContentGenerator(
...     BalancedAccuracyEvaluator(
...         AccuracyState(
...             y_true=np.array([1, 0, 0, 1, 1]),
...             y_pred=np.array([1, 0, 0, 1, 1]),
...             y_true_name="target",
...             y_pred_name="pred",
...         )
...     )
... )
>>> generator
BalancedAccuracyContentGenerator(
  (evaluator): BalancedAccuracyEvaluator(
      (state): AccuracyState(y_true=(5,), y_pred=(5,), y_true_name='target', y_pred_name='pred', nan_policy='propagate')
    )
)
arkas.content.BalancedAccuracyContentGenerator.from_state classmethod

Instantiate a BalancedAccuracyContentGenerator object from a state.

Parameters:

Name Type Description Default
state AccuracyState

The state with the data to analyze.

required

Returns:

Type Description
BalancedAccuracyContentGenerator

The instantiated object.

Example usage:

>>> import numpy as np
>>> from arkas.content import BalancedAccuracyContentGenerator
>>> from arkas.state import AccuracyState
>>> content = BalancedAccuracyContentGenerator.from_state(
...     AccuracyState(
...         y_true=np.array([1, 0, 0, 1, 1]),
...         y_pred=np.array([1, 0, 0, 1, 1]),
...         y_true_name="target",
...         y_pred_name="pred",
...     )
... )
>>> content
BalancedAccuracyContentGenerator(
  (evaluator): BalancedAccuracyEvaluator(
      (state): AccuracyState(y_true=(5,), y_pred=(5,), y_true_name='target', y_pred_name='pred', nan_policy='propagate')
    )
)

arkas.content.BaseContentGenerator

Bases: ABC

Define the base class to implement a HTML Content Generator.

Example usage:

>>> import numpy as np
>>> from arkas.content import AccuracyContentGenerator
>>> from arkas.evaluator2 import AccuracyEvaluator
>>> from arkas.state import AccuracyState
>>> content = AccuracyContentGenerator(
...     AccuracyEvaluator(
...         AccuracyState(
...             y_true=np.array([1, 0, 0, 1, 1]),
...             y_pred=np.array([1, 0, 0, 1, 1]),
...             y_true_name="target",
...             y_pred_name="pred",
...         )
...     )
... )
>>> content
AccuracyContentGenerator(
  (evaluator): AccuracyEvaluator(
      (state): AccuracyState(y_true=(5,), y_pred=(5,), y_true_name='target', y_pred_name='pred', nan_policy='propagate')
    )
)
arkas.content.BaseContentGenerator.compute abstractmethod
compute() -> BaseContentGenerator

Compute the content and return a new content generator.

Returns:

Type Description
BaseContentGenerator

A new content generator with the computed content.

Example usage:

>>> import numpy as np
>>> from arkas.content import AccuracyContentGenerator
>>> from arkas.evaluator2 import AccuracyEvaluator
>>> from arkas.state import AccuracyState
>>> content = AccuracyContentGenerator(
...     AccuracyEvaluator(
...         AccuracyState(
...             y_true=np.array([1, 0, 0, 1, 1]),
...             y_pred=np.array([1, 0, 0, 1, 1]),
...             y_true_name="target",
...             y_pred_name="pred",
...         )
...     )
... )
>>> content
AccuracyContentGenerator(
  (evaluator): AccuracyEvaluator(
      (state): AccuracyState(y_true=(5,), y_pred=(5,), y_true_name='target', y_pred_name='pred', nan_policy='propagate')
    )
)
>>> content2 = content.compute()
>>> content2
ContentGenerator()
arkas.content.BaseContentGenerator.equal abstractmethod
equal(other: Any, equal_nan: bool = False) -> bool

Indicate if two content generators are equal or not.

Parameters:

Name Type Description Default
other Any

The other content generator to compare.

required
equal_nan bool

Whether to compare NaN's as equal. If True, NaN's in both objects will be considered equal.

False

Returns:

Type Description
bool

True if the two content generators are equal, otherwise False.

Example usage:

>>> import numpy as np
>>> from arkas.content import AccuracyContentGenerator
>>> from arkas.evaluator2 import AccuracyEvaluator
>>> from arkas.state import AccuracyState
>>> content1 = AccuracyContentGenerator(
...     AccuracyEvaluator(
...         AccuracyState(
...             y_true=np.array([1, 0, 0, 1, 1]),
...             y_pred=np.array([1, 0, 0, 1, 1]),
...             y_true_name="target",
...             y_pred_name="pred",
...         )
...     )
... )
>>> content2 = AccuracyContentGenerator(
...     AccuracyEvaluator(
...         AccuracyState(
...             y_true=np.array([1, 0, 0, 1, 1]),
...             y_pred=np.array([1, 0, 0, 1, 1]),
...             y_true_name="target",
...             y_pred_name="pred",
...         )
...     )
... )
>>> content3 = AccuracyContentGenerator(
...     AccuracyEvaluator(
...         AccuracyState(
...             y_true=np.array([1, 0, 0, 0, 0]),
...             y_pred=np.array([1, 0, 0, 1, 1]),
...             y_true_name="target",
...             y_pred_name="pred",
...         )
...     )
... )
>>> content1.equal(content2)
True
>>> content1.equal(content3)
False
arkas.content.BaseContentGenerator.generate_body abstractmethod
generate_body(
    number: str = "",
    tags: Sequence[str] = (),
    depth: int = 0,
) -> str

Return the HTML body associated to the content.

Parameters:

Name Type Description Default
number str

The section number, if any.

''
tags Sequence[str]

The tags associated to the content section, if any.

()
depth int

The depth in the content section, if any.

0

Returns:

Type Description
str

The HTML body associated to the content section.

Example usage:

>>> import numpy as np
>>> from arkas.content import AccuracyContentGenerator
>>> from arkas.evaluator2 import AccuracyEvaluator
>>> from arkas.state import AccuracyState
>>> content = AccuracyContentGenerator(
...     AccuracyEvaluator(
...         AccuracyState(
...             y_true=np.array([1, 0, 0, 1, 1]),
...             y_pred=np.array([1, 0, 0, 1, 1]),
...             y_true_name="target",
...             y_pred_name="pred",
...         )
...     )
... )
>>> content.generate_body()
arkas.content.BaseContentGenerator.generate_toc abstractmethod
generate_toc(
    number: str = "",
    tags: Sequence[str] = (),
    depth: int = 0,
    max_depth: int = 1,
) -> str

Return the HTML table of content (TOC) associated to the section.

Parameters:

Name Type Description Default
number str

The section number associated to the section, if any.

''
tags Sequence[str]

The tags associated to the section, if any.

()
depth int

The depth in the report, if any.

0
max_depth int

The maximum depth to generate in the TOC.

1

Returns:

Type Description
str

The HTML table of content associated to the section.

Example usage:

>>> import numpy as np
>>> from arkas.content import AccuracyContentGenerator
>>> from arkas.evaluator2 import AccuracyEvaluator
>>> from arkas.state import AccuracyState
>>> content = AccuracyContentGenerator(
...     AccuracyEvaluator(
...         AccuracyState(
...             y_true=np.array([1, 0, 0, 1, 1]),
...             y_pred=np.array([1, 0, 0, 1, 1]),
...             y_true_name="target",
...             y_pred_name="pred",
...         )
...     )
... )
>>> content.generate_toc()

arkas.content.ColumnCooccurrenceContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that returns pairwise column co- occurrence.

Parameters:

Name Type Description Default
state ColumnCooccurrenceState

The state with the co-occurrence matrix.

required

Example usage:

>>> import numpy as np
>>> from arkas.content import ColumnCooccurrenceContentGenerator
>>> from arkas.state import ColumnCooccurrenceState
>>> content = ColumnCooccurrenceContentGenerator(
...     ColumnCooccurrenceState(matrix=np.ones((3, 3)), columns=["a", "b", "c"])
... )
>>> content
ColumnCooccurrenceContentGenerator(
  (state): ColumnCooccurrenceState(matrix=(3, 3), figure_config=MatplotlibFigureConfig())
)

arkas.content.ColumnCorrelationContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that analyzes the correlation between 1 target column and other columns.

Parameters:

Name Type Description Default
evaluator ColumnCorrelationEvaluator

The evaluator object to compute the correlations.

required

Example usage:

>>> import polars as pl
>>> from arkas.content import ColumnCorrelationContentGenerator
>>> from arkas.evaluator2 import ColumnCorrelationEvaluator
>>> from arkas.state import TargetDataFrameState
>>> frame = pl.DataFrame(
...     {
...         "col1": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0],
...         "col2": [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0],
...         "col3": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0],
...     },
... )
>>> content = ColumnCorrelationContentGenerator(
...     ColumnCorrelationEvaluator(TargetDataFrameState(frame, target_column="col3"))
... )
>>> content
ColumnCorrelationContentGenerator(
  (evaluator): ColumnCorrelationEvaluator(
      (state): TargetDataFrameState(dataframe=(7, 3), target_column='col3', nan_policy='propagate', figure_config=MatplotlibFigureConfig())
    )
)
arkas.content.ColumnCorrelationContentGenerator.from_state classmethod

Instantiate a ColumnCorrelationContentGenerator object from a state.

Parameters:

Name Type Description Default
state TargetDataFrameState

The state with the data to analyze.

required

Returns:

Type Description
ColumnCorrelationContentGenerator

The instantiated object.

Example usage:

>>> import polars as pl
>>> from arkas.content import ColumnCorrelationContentGenerator
>>> from arkas.state import TargetDataFrameState
>>> frame = pl.DataFrame(
...     {
...         "col1": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0],
...         "col2": [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0],
...         "col3": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0],
...     },
... )
>>> content = ColumnCorrelationContentGenerator.from_state(
...     TargetDataFrameState(frame, target_column="col3")
... )
>>> content
ColumnCorrelationContentGenerator(
  (evaluator): ColumnCorrelationEvaluator(
      (state): TargetDataFrameState(dataframe=(7, 3), target_column='col3', nan_policy='propagate', figure_config=MatplotlibFigureConfig())
    )
)

arkas.content.ContentGenerator

Bases: BaseSectionContentGenerator

Implement a section that analyze accuracy states.

Parameters:

Name Type Description Default
content str

The HTML content.

''

Example usage:

>>> import numpy as np
>>> from arkas.content import ContentGenerator
>>> generator = ContentGenerator("meow")
>>> generator
ContentGenerator()
>>> generator.generate_content()
'meow'

arkas.content.ContentGeneratorDict

Bases: BaseContentGenerator

Implement a content generator that combines a mapping of content generators.

Parameters:

Name Type Description Default
generators Mapping[str, BaseContentGenerator]

The mapping of content generators.

required

Example usage:

>>> from arkas.content import ContentGeneratorDict, ContentGenerator
>>> content = ContentGeneratorDict(
...     {
...         "one": ContentGenerator(),
...         "two": ContentGenerator("meow"),
...     }
... )
>>> content
ContentGeneratorDict(
  (one): ContentGenerator()
  (two): ContentGenerator()
)

arkas.content.ContinuousSeriesContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that analyzes a Series with continuous values.

Parameters:

Name Type Description Default
state SeriesState

The state containing the Series to analyze.

required

Example usage:

>>> import polars as pl
>>> from arkas.content import ContinuousSeriesContentGenerator
>>> from arkas.state import SeriesState
>>> content = ContinuousSeriesContentGenerator(
...     SeriesState(pl.Series("col1", [1, 2, 3, 4, 5, 6, 7]))
... )
>>> content
ContinuousSeriesContentGenerator(
  (state): SeriesState(name='col1', values=(7,), figure_config=MatplotlibFigureConfig())
)

arkas.content.CorrelationContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that analyzes the correlation between two columns.

Parameters:

Name Type Description Default
evaluator CorrelationEvaluator

The evaluator that computes correlation.

required
plotter CorrelationPlotter

The data correlation plotter.

required

Example usage:

>>> import polars as pl
>>> from arkas.content import CorrelationContentGenerator
>>> from arkas.state import TwoColumnDataFrameState
>>> frame = pl.DataFrame(
...     {
...         "col1": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0],
...         "col2": [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0],
...     },
... )
>>> state = TwoColumnDataFrameState(frame, column1="col1", column2="col2")
>>> content = CorrelationContentGenerator(
...     evaluator=CorrelationEvaluator(state),
...     plotter=CorrelationPlotter(state),
... )
>>> content
CorrelationContentGenerator(
  (evaluator): CorrelationEvaluator(
      (state): TwoColumnDataFrameState(dataframe=(7, 2), column1='col1', column2='col2', nan_policy='propagate', figure_config=MatplotlibFigureConfig())
    )
  (plotter): CorrelationPlotter(
      (state): TwoColumnDataFrameState(dataframe=(7, 2), column1='col1', column2='col2', nan_policy='propagate', figure_config=MatplotlibFigureConfig())
    )
)
arkas.content.CorrelationContentGenerator.from_state classmethod

Instantiate a CorrelationContentGenerator object from a state.

Parameters:

Name Type Description Default
state TwoColumnDataFrameState

The state with the data to analyze.

required

Returns:

Type Description
CorrelationContentGenerator

The instantiated object.

Example usage:

>>> import polars as pl
>>> from arkas.content import CorrelationContentGenerator
>>> from arkas.state import TwoColumnDataFrameState
>>> frame = pl.DataFrame(
...     {
...         "col1": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0],
...         "col2": [7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0],
...     },
... )
>>> content = CorrelationContentGenerator.from_state(
...     TwoColumnDataFrameState(frame, column1="col1", column2="col2")
... )
>>> content
CorrelationContentGenerator(
  (evaluator): CorrelationEvaluator(
      (state): TwoColumnDataFrameState(dataframe=(7, 2), column1='col1', column2='col2', nan_policy='propagate', figure_config=MatplotlibFigureConfig())
    )
  (plotter): CorrelationPlotter(
      (state): TwoColumnDataFrameState(dataframe=(7, 2), column1='col1', column2='col2', nan_policy='propagate', figure_config=MatplotlibFigureConfig())
    )
)

arkas.content.HexbinColumnContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that makes a 2D hexagonal binning plot of data points.

Parameters:

Name Type Description Default
state ScatterDataFrameState

The state containing the DataFrame to analyze.

required

Example usage:

>>> import polars as pl
>>> from arkas.content import HexbinColumnContentGenerator
>>> from arkas.state import ScatterDataFrameState
>>> dataframe = pl.DataFrame(
...     {
...         "col1": [0, 1, 1, 0, 0, 1, 0],
...         "col2": [0, 1, 0, 1, 0, 1, 0],
...         "col3": [0, 0, 0, 0, 1, 1, 1],
...     }
... )
>>> content = HexbinColumnContentGenerator(
...     ScatterDataFrameState(dataframe, x="col1", y="col2")
... )
>>> content
HexbinColumnContentGenerator(
  (state): ScatterDataFrameState(dataframe=(7, 3), x='col1', y='col2', color=None, nan_policy='propagate', figure_config=MatplotlibFigureConfig())
)

arkas.content.NullValueContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that analyzes the number of null values per column.

Parameters:

Name Type Description Default
state NullValueState

The state containing the number of null values per column.

required

Example usage:

>>> import numpy as np
>>> from arkas.content import NullValueContentGenerator
>>> from arkas.state import NullValueState
>>> content = NullValueContentGenerator(
...     NullValueState(
...         null_count=np.array([0, 1, 2]),
...         total_count=np.array([5, 5, 5]),
...         columns=["col1", "col2", "col3"],
...     )
... )
>>> content
NullValueContentGenerator(
  (state): NullValueState(num_columns=3, figure_config=MatplotlibFigureConfig())
)

arkas.content.NumericSummaryContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that summarizes the numeric columns of a DataFrame.

Parameters:

Name Type Description Default
state DataFrameState

The state containing the DataFrame to analyze.

required

Example usage:

>>> import polars as pl
>>> from arkas.content import NumericSummaryContentGenerator
>>> from arkas.state import DataFrameState
>>> dataframe = pl.DataFrame(
...     {
...         "col1": [0, 1, 1, 0, 0, 1, 0],
...         "col2": [0, 1, 0, 1, 0, 1, 0],
...         "col3": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0],
...     }
... )
>>> content = NumericSummaryContentGenerator(DataFrameState(dataframe))
>>> content
NumericSummaryContentGenerator(
  (state): DataFrameState(dataframe=(7, 3), nan_policy='propagate', figure_config=MatplotlibFigureConfig())
)

arkas.content.PlotColumnContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that plots the content of each column.

Parameters:

Name Type Description Default
state DataFrameState

The state containing the DataFrame to analyze.

required

Example usage:

>>> import polars as pl
>>> from arkas.content import PlotColumnContentGenerator
>>> from arkas.state import DataFrameState
>>> dataframe = pl.DataFrame(
...     {
...         "col1": [0, 1, 1, 0, 0, 1, 0],
...         "col2": [0, 1, 0, 1, 0, 1, 0],
...         "col3": [0, 0, 0, 0, 1, 1, 1],
...     }
... )
>>> content = PlotColumnContentGenerator(DataFrameState(dataframe))
>>> content
PlotColumnContentGenerator(
  (state): DataFrameState(dataframe=(7, 3), nan_policy='propagate', figure_config=MatplotlibFigureConfig())
)

arkas.content.ScatterColumnContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that plots the content of each column.

Parameters:

Name Type Description Default
state ScatterDataFrameState

The state containing the DataFrame to analyze.

required

Example usage:

>>> import polars as pl
>>> from arkas.content import ScatterColumnContentGenerator
>>> from arkas.state import ScatterDataFrameState
>>> dataframe = pl.DataFrame(
...     {
...         "col1": [0, 1, 1, 0, 0, 1, 0],
...         "col2": [0, 1, 0, 1, 0, 1, 0],
...         "col3": [0, 0, 0, 0, 1, 1, 1],
...     }
... )
>>> content = ScatterColumnContentGenerator(
...     ScatterDataFrameState(dataframe, x="col1", y="col2")
... )
>>> content
ScatterColumnContentGenerator(
  (state): ScatterDataFrameState(dataframe=(7, 3), x='col1', y='col2', color=None, nan_policy='propagate', figure_config=MatplotlibFigureConfig())
)

arkas.content.SummaryContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that returns a summary of a DataFrame.

Parameters:

Name Type Description Default
state DataFrameState

The state containing the DataFrame to analyze.

required

Example usage:

>>> import polars as pl
>>> from arkas.content import SummaryContentGenerator
>>> from arkas.state import DataFrameState
>>> content = SummaryContentGenerator(
...     DataFrameState(
...         pl.DataFrame(
...             {
...                 "col1": [0, 1, 1, 0, 0, 1, 0],
...                 "col2": [0, 1, 0, 1, 0, 1, 0],
...                 "col3": [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0],
...             }
...         )
...     )
... )
>>> content
SummaryContentGenerator(
  (state): DataFrameState(dataframe=(7, 3), nan_policy='propagate', figure_config=MatplotlibFigureConfig())
)

arkas.content.TemporalContinuousColumnContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that analyzes the temporal distribution of a column with continuous values.

Parameters:

Name Type Description Default
state TemporalColumnState

The state containing the column to analyze.

required

Example usage:

>>> from datetime import datetime, timezone
>>> import polars as pl
>>> from arkas.content import TemporalContinuousColumnContentGenerator
>>> from arkas.state import TemporalColumnState
>>> frame = pl.DataFrame(
...     {
...         "col1": [0, 1, 0, 1],
...         "col2": [0, 1, 2, 3],
...         "datetime": [
...             datetime(year=2020, month=1, day=3, tzinfo=timezone.utc),
...             datetime(year=2020, month=2, day=3, tzinfo=timezone.utc),
...             datetime(year=2020, month=3, day=3, tzinfo=timezone.utc),
...             datetime(year=2020, month=4, day=3, tzinfo=timezone.utc),
...         ],
...     },
...     schema={
...         "col1": pl.Int64,
...         "col2": pl.Int64,
...         "datetime": pl.Datetime(time_unit="us", time_zone="UTC"),
...     },
... )
>>> content = TemporalContinuousColumnContentGenerator(
...     TemporalColumnState(frame, target_column="col2", temporal_column="datetime")
... )
>>> content
TemporalContinuousColumnContentGenerator(
  (state): TemporalColumnState(dataframe=(4, 3), target_column='col2', temporal_column='datetime', period=None, nan_policy='propagate', figure_config=MatplotlibFigureConfig())
)

arkas.content.TemporalNullValueContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that analyzes the temporal distribution of null values.

Parameters:

Name Type Description Default
state TemporalDataFrameState

The state containing the DataFrame to analyze.

required

Example usage:

>>> from datetime import datetime, timezone
>>> import polars as pl
>>> from arkas.content import TemporalNullValueContentGenerator
>>> from arkas.state import TemporalDataFrameState
>>> dataframe = pl.DataFrame(
...     {
...         "col1": [0, 1, 1, 0],
...         "col2": [0, 1, 0, 1],
...         "col3": [1, 0, 0, 0],
...         "datetime": [
...             datetime(year=2020, month=1, day=3, tzinfo=timezone.utc),
...             datetime(year=2020, month=2, day=3, tzinfo=timezone.utc),
...             datetime(year=2020, month=3, day=3, tzinfo=timezone.utc),
...             datetime(year=2020, month=4, day=3, tzinfo=timezone.utc),
...         ],
...     },
...     schema={
...         "col1": pl.Int64,
...         "col2": pl.Int64,
...         "col3": pl.Int64,
...         "datetime": pl.Datetime(time_unit="us", time_zone="UTC"),
...     },
... )
>>> content = TemporalNullValueContentGenerator(
...     TemporalDataFrameState(dataframe, temporal_column="datetime")
... )
>>> content
TemporalNullValueContentGenerator(
  (state): TemporalDataFrameState(dataframe=(4, 4), temporal_column='datetime', period=None, nan_policy='propagate', figure_config=MatplotlibFigureConfig())
)

arkas.content.TemporalPlotColumnContentGenerator

Bases: BaseSectionContentGenerator

Implement a content generator that plots the content of each column.

Parameters:

Name Type Description Default
state TemporalDataFrameState

The state containing the DataFrame to analyze.

required

Example usage:

>>> from datetime import datetime, timezone
>>> import polars as pl
>>> from arkas.content import TemporalPlotColumnContentGenerator
>>> from arkas.state import TemporalDataFrameState
>>> dataframe = pl.DataFrame(
...     {
...         "col1": [0, 1, 1, 0],
...         "col2": [0, 1, 0, 1],
...         "col3": [1, 0, 0, 0],
...         "datetime": [
...             datetime(year=2020, month=1, day=3, tzinfo=timezone.utc),
...             datetime(year=2020, month=2, day=3, tzinfo=timezone.utc),
...             datetime(year=2020, month=3, day=3, tzinfo=timezone.utc),
...             datetime(year=2020, month=4, day=3, tzinfo=timezone.utc),
...         ],
...     },
...     schema={
...         "col1": pl.Int64,
...         "col2": pl.Int64,
...         "col3": pl.Int64,
...         "datetime": pl.Datetime(time_unit="us", time_zone="UTC"),
...     },
... )
>>> content = TemporalPlotColumnContentGenerator(
...     TemporalDataFrameState(dataframe, temporal_column="datetime")
... )
>>> content
TemporalPlotColumnContentGenerator(
  (state): TemporalDataFrameState(dataframe=(4, 4), temporal_column='datetime', period=None, nan_policy='propagate', figure_config=MatplotlibFigureConfig())
)