Panelsplit
A tool for performing cross-validation with panel data
Install / Use
/learn @4Freye/PanelsplitREADME
panelsplit: a tool for panel data analysis
panelsplit is a Python package designed to facilitate time series cross-validation when working with multiple entities (aka panel data). This tool is useful for handling panel data in various stages throughout the data pipeline, including feature engineering, hyper-parameter tuning, and model estimation.
Installation
panelsplit is tested for compatibility with python versions >= 3.11. You can install panelsplit using pip:
pip install panelsplit
Documentation
To read the documentation, visit here.
Example Usage
import pandas as pd
from panelsplit.cross_validation import PanelSplit
# Generate example data
num_countries = 2
years = range(2001, 2004)
num_years = len(years)
data_dict = {
'country_id': [c for c in range(1, num_countries + 1) for _ in years],
'year': [year for _ in range(num_countries) for year in years],
'y': np.random.normal(0, 1, num_countries * num_years),
'x1': np.random.normal(0, 1, num_countries * num_years),
'x2': np.random.normal(0, 1, num_countries * num_years)
}
panel_data = pd.DataFrame(data_dict)
panel_split = PanelSplit(periods = panel_data.year, n_splits =2)
splits = panel_split.split()
for train_idx, test_idx in splits:
print("Train:"); display(panel_data.loc[train_idx])
print("Test:"); display(panel_data.loc[test_idx])
For more examples and detailed usage instructions, refer to the examples directory in this repository. Also feel free to check out an introductory article on panelsplit.
Background
Work on panelsplit started at EconAI in December 2023 and has been under active development since then.
Contributing
Contributions to panelsplit are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Related Skills
node-connect
339.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
83.9kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
339.3kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
