Skip to main content

Date-aware time series cross-validator for deterministic train/test splits.

Project description

TimeSeriesSplitByDate

Date-aware splitting utility for time series model evaluation.

Installation

pip install timeseriessplitbydate

For local development:

pip install -e .

Quickstart

import pandas as pd

from timeseriessplitbydate import TimeSeriesSplitByDate

X = pd.DataFrame(
    {
        "feature": range(8),
        "event_date": pd.date_range("2024-01-01", periods=8, freq="D"),
    }
)

splitter = TimeSeriesSplitByDate(
    n_splits=3,
    date_col="event_date",
    split_by="days",
)

for train_idx, test_idx in splitter.split(X):
    print(train_idx, test_idx)

How it differs from sklearn TimeSeriesSplit

  • Supports date-column-driven splitting (date_col) for DataFrame inputs.
  • Adds calendar-aware modes:
    • split_by="days": equal-width date-range intervals.
    • split_by="weeks": adjacent week folds with week_start="monday" (default) or week_start="sunday".
    • split_by="months": adjacent month folds.
  • Supports external date data via set_date_data(...).
  • Falls back to sklearn TimeSeriesSplit when no date source is provided.
  • In date-based modes, gap is interpreted as calendar days.

Development

pip install -e .[dev]
ruff check .
pytest

More Documentation

  • Usage guide: docs/usage.md
  • Runnable demo: examples/basic_usage.py

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

timeseriessplitbydate-0.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

timeseriessplitbydate-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file timeseriessplitbydate-0.1.0.tar.gz.

File metadata

  • Download URL: timeseriessplitbydate-0.1.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for timeseriessplitbydate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8a90750dc2243cce067f9afd57b5ac89d97b8e7fec2209a1e68fed1072e3bc12
MD5 61d55b86c45b71ca5cb4ebb8032954a1
BLAKE2b-256 3cd66de99695f8655bb8512625b021bd1905a6c3dea4ca07bdbd5556f75c222b

See more details on using hashes here.

File details

Details for the file timeseriessplitbydate-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for timeseriessplitbydate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3908a5177fac6eb3d5780b14cad51f6a8444017283ac99965a51fc6fbd3fb736
MD5 30685d0a820fe1e0b66de1a5877b8c11
BLAKE2b-256 96dc880ea1dc53ab2bf9bcad92a7afd1222c0ac5afbe1bbae87086bc501d324b

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