prepare_trend_graph
prepare_trend_graph(df, ts_id, var=None)Line-plot the mean (with standard-error bars) of variables over time.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| df | pd.DataFrame | Data frame containing ts_id and the numeric variables to plot. |
required |
| ts_id | str | Column name of the time-series identifier. | required |
| var | Sequence[str] | None | Variables to plot. Defaults to all numeric columns other than ts_id. |
None |
Returns
| Name | Type | Description |
|---|---|---|
| TrendGraphResult | df (columns variable, ts_id, mean, se) and the Plotly fig. |
Examples
Basic — mean of a single variable over time, with standard-error bars:
import expdpy as ex
from expdpy.data import load_kuznets
df = load_kuznets()
ex.prepare_trend_graph(df, ts_id="year", var=["gini_regional"]).figAdvanced — several variables on one chart, with the aggregated frame from .df:
result = ex.prepare_trend_graph(
df, ts_id="year", var=["gini_regional", "trade_share"]
)
result.fig
result.df.head()