pyxtpanel
Panel-data management, exploration and statistical tests for Python, validated against Stata.
pyxtpanel brings the xt layer of Stata to Python: declare a panel once (xtset), describe it
(xtdescribe, xtsum, xttab, xttrans), take lags, differences and within transformations on the
calendar, and run the statistical tests of panel data that need no estimator. It estimates no model:
it is the foundation under the estimation packages
pyxtabond2, pyxthreg
and pyxtdpthresh, and a tool of its own for anyone who
holds panel data in pandas.
pip install pyxtpanel # numpy, pandas, scipy
pip install "pyxtpanel[plot]" # adds matplotlib for the figures
Python 3.10 or later. Alpha (0.x): the API may change until 1.0.
A first panel
import numpy as np
import pandas as pd
import pyxtpanel as xt
rng = np.random.default_rng(0)
df = pd.DataFrame(
{
"country": np.repeat([f"C{i:02d}" for i in range(20)], 15),
"year": np.tile(np.arange(2000, 2015), 20),
"gdp": rng.normal(8, 1, size=300),
}
)
df = df.drop(index=[5, 6, 47, 130]) # real data have holes
panel = xt.xtset(df, "country", "year") # xtset country year
print(panel.xtsum("gdp").summary()) # xtsum gdp: overall, between, within
print(panel.operate("L.gdp", "D.gdp").head(3)) # L.gdp D.gdp, on the calendar
print(panel.audit().summary()) # what to know before modelling
print(panel.cross_section_dependence("gdp", test="pesaran_cd").pvalue) # xtcsd
The panel is an immutable object: your DataFrame is never modified, every function returns a new
object, and every result has .to_frame(), .summary(), .to_markdown() and .to_latex().
Messages and texts are in English or French (xt.set_options(lang="fr")).
What is inside
| You want to | Look at |
|---|---|
Declare and manage a panel: dates, delta, holes, tsfill, selection, .dta input and output |
xtset, PanelData.tsfill, xt.read_stata |
Lag, lead, difference, seasonal difference, with Stata's notation ("L2D.x", "L(1/3).x") |
PanelData.operate, lag, diff |
| Remove unit means, take between means, forward orthogonal deviations, rolling windows | within, between, fod, rolling |
| Describe a panel as Stata does | xtdescribe, xtsum, xttab, xttrans, xtcorr |
| Understand an unbalanced panel (tools that Stata and R do not have) | gap_types, balance_cost, unbalancedness, usable_equations, spells, audit |
| Test unit roots, cross-sectional dependence, serial correlation, cointegration, causality, slope heterogeneity | 35 tests: xt.list_tests(), PanelData.unit_root, xt.run_test |
| Test the residuals of any estimator from bare arrays | hansen, sargan, hausman, wald, ar_test, breusch_pagan, white, ... |
Draw the panel (extra plot) |
PanelData.plot("lines"), "states", "attrition", ... |
| Feed an estimation package | PanelData.arrays, the frozen array contract |
Why trust it
Every function that has a Stata equivalent is compared with Stata 17 MP on shared datasets, and the reference results are frozen in the test suite, so the 3 500 tests run without Stata. The statistical tests agree with Stata to 1e-6 or better, in most cases to 1e-9. A random campaign draws 160 panels (holes, entry and exit, any identifiers, any time origin, Stata date formats) and compares 73 quantities per panel with Stata; fresh runs of 3 700 more panels agree too. Where Stata does something odd, the package either reproduces it on purpose and says so, or documents the difference (documentation, annex D and part 9).
Learn more
- Documentation: one reference document, from a first panel to the formulas; every Python example in it is run by the test suite.
- Examples: four scripts, a country-by-year panel, the Hansen (1999) firm investment data, an unbalanced panel, and the residual tests of an estimator.
- CHANGELOG, CONTRIBUTING and CITATION.cff.
Licence
MIT, see LICENSE. Where the formulas, the embedded numerical tables and the reused code come from, and what is not copied (no Stata code), is in NOTICE.md. Stata is a registered trademark of StataCorp LLC; this package is not affiliated with it.
Metadata
Release files for pyxtpanel 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyxtpanel-0.0.2.tar.gz | 326.0 kB | With provenance | Details for pyxtpanel-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyxtpanel-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for pyxtpanel-0.0.2-py3-none-any.whl |
Total release size: 695.1 kB
Release files / pyxtpanel-0.0.2.tar.gz
| Download URL | pyxtpanel-0.0.2.tar.gz |
|---|---|
| Size | 326.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c4d8fef58be3b328870a4a8a471a1b15bd77be5152ffe5cc8720933d4904beee
|
|
BLAKE2b-256 checksum How to use checksums |
c6346af8faa5a6097d878f694e6640e44b7c7d5d22cf67e2b1197fe014652345
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / pyxtpanel-0.0.2-py3-none-any.whl
| Download URL | pyxtpanel-0.0.2-py3-none-any.whl |
|---|---|
| Size | 369.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
470b3938269cc9aef78e492bb47a5f6b6234444fd761291af1a972d027e1f9fe
|
|
BLAKE2b-256 checksum How to use checksums |
9dff2ce83fa64e9ad4036e40ca1d7adff1a97614a09a55f3090c349523410378
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logSecurity for pyxtpanel 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for pyxtpanel-0.0.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.