explore_value_heatmap

source

explore_value_heatmap(
    df,
    var,
    *,
    entity=None,
    time=None,
    standardize='none',
    aggfunc='mean',
    max_units=200,
    sort_by='mean',
    title=None,
    subtitle=None,
)

Heatmap of a variable over the unit-by-time grid (units by periods, colour = value).

Parameters

Name Type Description Default
df pd.DataFrame Panel data frame. required
var str Numeric variable to display. required
entity str | None Cross-sectional (unit) identifier. Defaults to the panel entity. None
time str | None Time identifier. Defaults to the panel time. None
standardize Literal['none', 'by_time', 'by_entity', 'global'] "none" shows raw values; "global" z-scores over all cells; "by_time" / "by_entity" z-score within each period / unit (revealing relative position). 'none'
aggfunc str Aggregator for duplicate (entity, time) cells (default "mean"). 'mean'
max_units int | None Cap on the number of units drawn (evenly sampled above it). 200
sort_by Literal['mean', 'first_value', 'label'] Row order: by "mean" (default, descending), "first_value" or "label". 'mean'

Returns

Name Type Description
ValueHeatmapResult df (the unit-by-time pivot) 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_value_heatmap(df, var="gini_regional", standardize="by_time").fig