Skip to main content

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyxtpanel 0.0.1
File Size Uploaded Provenance Actions
pyxtpanel-0.0.1.tar.gz 316.9 kB With provenance Details for pyxtpanel-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyxtpanel 0.0.1
File Interpreter ABI Platform Actions
pyxtpanel-0.0.1-py3-none-any.whl Python 3 none any Details for pyxtpanel-0.0.1-py3-none-any.whl

Total release size: 677.6 kB

Release files / pyxtpanel-0.0.1.tar.gz

Download URL pyxtpanel-0.0.1.tar.gz
Size 316.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0a7be26c74a4ac8975ac98f7f45d38aebae29f6f8c6ba83add55071173c41722
BLAKE2b-256 checksum
How to use checksums
59bedc484512a2ad31a472cd5d94a61d54e4fcf7178f4d918482b401e584adbe
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 log

Release files / pyxtpanel-0.0.1-py3-none-any.whl

Download URL pyxtpanel-0.0.1-py3-none-any.whl
Size 360.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
260220df2ed1a28167df56fa446f092cbefaceacc57b4a589c0b76de4ec549a7
BLAKE2b-256 checksum
How to use checksums
b385a68a90cd2691c91354da561f3e1d6f0e297f9a1e8159fa1186b369bb3a99
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 log

Security for pyxtpanel 0.0.1

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.

Select from 2 files

Attestation for pyxtpanel-0.0.1.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 log

A 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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page