explore_xtsum_table
source
explore_xtsum_table(
df,
var= None ,
* ,
entity= None ,
time= None ,
digits= 3 ,
caption= 'Within/Between Variation (xtsum)' ,
)
Decompose each variable’s variation into overall / between / within (Stata xtsum).
For every numeric variable the table reports the overall mean and standard deviation, the between standard deviation (across unit means), and the within standard deviation (variation over time inside a unit), plus the number of observations, units and the average number of periods per unit.
Parameters
df
pd .DataFrame
Panel data frame.
required
var
Sequence [str ] | None
Variables to summarise. Defaults to all numeric/logical columns except the identifiers.
None
entity
str | None
Cross-sectional (unit) identifier. Defaults to the panel entity declared via :func:expdpy.set_panel.
None
time
str | None
Time identifier (used only to exclude it from the default var list). Defaults to the panel time.
None
digits
int
Decimals for the formatted statistics.
3
caption
str
Great Tables header title.
'Within/Between Variation (xtsum)'
Returns
XtsumTableResult
df (long within/between frame) and gt (the Great Tables object).
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_xtsum_table(df, var= ["gini_regional" , "log_gdp_pc" ]).gt
Mean
Std. dev.
Min.
Max.
N
n units
T-bar
Regional inequality (Gini)
Overall
0.273
0.091
0.020
0.568
880
80
11.000
Between
0.078
0.068
0.468
Within
0.048
0.076
0.451
Log GDP per capita
Overall
9.205
1.490
6.275
11.918
880
80
11.000
Between
1.482
6.483
11.839
Within
0.222
8.436
10.051
Overall = pooled. Between = across unit means. Within = over time inside a unit (deviations from the unit mean, recentered on the grand mean).