Skip to main content

A tool for panel data analysis.

Project description

PyPI - Version DOI

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

panelsplit-2.0.5.tar.gz (240.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

panelsplit-2.0.5-py3-none-any.whl (54.5 kB view details)

Uploaded Python 3

File details

Details for the file panelsplit-2.0.5.tar.gz.

File metadata

  • Download URL: panelsplit-2.0.5.tar.gz
  • Upload date:
  • Size: 240.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for panelsplit-2.0.5.tar.gz
Algorithm Hash digest
SHA256 22d0980a4e466e7ab7be5dc37a1dd1889b48dd2678f99d92af2e80bae6daaa69
MD5 91770df56c8bf69dbe5046a76f0d5abc
BLAKE2b-256 5cf6af62e4c5880c395da60a3a1cc41dc9a2b58bcc524fdcf9301ba3c23e75ad

See more details on using hashes here.

File details

Details for the file panelsplit-2.0.5-py3-none-any.whl.

File metadata

  • Download URL: panelsplit-2.0.5-py3-none-any.whl
  • Upload date:
  • Size: 54.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for panelsplit-2.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3a165a99b7a05235f99e34e944609d40125ed86883b5eb78de4b6656bbc52ffd
MD5 88831f7ee9ec9bb93bbfa376a17adf4f
BLAKE2b-256 f49ba825c4808ac489eb6bed06d138e309627b02a8bcef84ba6280bc0b34efc7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page