Skip to main content

Time Series Extras (e.g. business day utilities) for Polars

Project description

polars-xdt

eXtra stuff for DateTimes

polars-xdt

PyPI version Read the docs!

eXtra stuff for DateTimes in Polars.

  • ✅ blazingly fast, written in Rust!
  • ✅ seamless Polars integration!
  • ✅ define your own custom holidays and weekends!

Installation

First, you need to install Polars.

Then, you'll need to install polars-xdt:

pip install polars-xdt

Then, if you can run

from datetime import date
import polars_xdt as xdt

print(xdt.date_range(date(2023, 1, 1), date(2023, 1, 10), eager=True))

it means installation all worked correctly!

Read the documentation for a little tutorial and API reference.

Basic Example

Say we start with

from datetime import date

import polars as pl
import polars_xdt  # noqa: F401


df = pl.DataFrame(
    {"date": [date(2023, 4, 3), date(2023, 9, 1), date(2024, 1, 4)]}
)

Let's shift Date forwards by 5 days, excluding Saturday and Sunday:

result = df.with_columns(
    date_shifted=pl.col("date").xdt.offset_by(
      '5bd',
      weekend=('Sat', 'Sun'),
    )
)
print(result)
shape: (3, 2)
┌────────────┬──────────────┐
│ date       ┆ date_shifted │
│ ---        ┆ ---          │
│ date       ┆ date         │
╞════════════╪══════════════╡
│ 2023-04-03 ┆ 2023-04-10   │
│ 2023-09-01 ┆ 2023-09-08   │
│ 2024-01-04 ┆ 2024-01-11   │
└────────────┴──────────────┘

You can also count the number of business days between two given dates, specify a custom calendar holiday, and create a date range excluding workdays.

Read the documentation for more examples!

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

polars_xdt-0.4.2.tar.gz (966.9 kB view details)

Uploaded Source

Built Distribution

polars_xdt-0.4.2-cp310-cp310-manylinux_2_34_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.34+ x86-64

File details

Details for the file polars_xdt-0.4.2.tar.gz.

File metadata

  • Download URL: polars_xdt-0.4.2.tar.gz
  • Upload date:
  • Size: 966.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.4.0

File hashes

Hashes for polars_xdt-0.4.2.tar.gz
Algorithm Hash digest
SHA256 2a574cdf66c95a501a66ab0bec1073d72cad782e80f99a9cc1d0339fcc98a1e1
MD5 574f24aeede499516c0be08b2f51947e
BLAKE2b-256 16be5cf994f89e148785a93cb8f050047b6d4752a22d06ac30063cd5aa1cece4

See more details on using hashes here.

Provenance

File details

Details for the file polars_xdt-0.4.2-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for polars_xdt-0.4.2-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 5569bd1ac748ff01ab8617391c1fbad17ddd0d0f9c4f0842667e14c4e0a2e8c3
MD5 c3546a42cddc2169635c5399b244ba66
BLAKE2b-256 b453f9ff58771f1cb80268ecc9218cb875c96186159d010d5cdbd5c951f81d42

See more details on using hashes here.

Provenance

Supported by

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