explore_distribution_over_time

source

explore_distribution_over_time(
    df,
    var,
    *,
    entity=None,
    time=None,
    style='ridgeline',
    bins=30,
    bandwidth=None,
    max_periods=24,
    title=None,
    subtitle=None,
)

Show how the distribution of var shifts across periods.

Parameters

Name Type Description Default
df pd.DataFrame Panel data frame. required
var str Numeric variable whose distribution is tracked. required
entity str | None Cross-sectional id (accepted for panel parity; the per-period distribution pools across units). Defaults to the panel entity. None
time str | None Time identifier. Defaults to the panel time. None
style Literal['ridgeline', 'animated_hist', 'animated_violin'] "ridgeline" (default; stacked per-period densities), "animated_hist" or "animated_violin" (Plotly animation over periods). 'ridgeline'
bins int Histogram bins (animated_hist and the KDE fallback). 30
bandwidth float | None KDE bandwidth (bw_method) for the ridgeline; None uses Scott’s rule. None
max_periods int | None Cap on the number of periods drawn (evenly sampled above it). 24

Returns

Name Type Description
DistributionOverTimeResult df (the complete-case (time, var) frame) and the Plotly fig.

Examples

import expdpy as ex
from expdpy.data import load_kuznets, load_kuznets_data_def

df = ex.set_labels(load_kuznets(), load_kuznets_data_def(), set_panel=True)
ex.explore_distribution_over_time(df, var="gini_regional").fig