Skip to main content

eXtra stuff for Dates and Times in 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
  • ✅ custom business-day arithmetic
  • ✅ convert to and from multiple time zones
  • ✅ format datetime in different locales
  • ✅ convert to Julian Dates
  • ✅ time-based EWMA

Installation

First, you need to install Polars.

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

pip install polars-xdt

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 as xdt


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=xdt.offset_by(
      'date',
      '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   │
└────────────┴──────────────┘

Note that polars-xdt also registers a xdt namespace in the Expression class, so you could equivalently write the above using pl.col('date').xdt.offset_by('5bd') (but note that then type-checking would not recognise the xdt attribute).

Read the documentation for more examples!

Logo

Thanks to Olha Urdeichuk for the illustration.

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.14.12.tar.gz (982.1 kB view details)

Uploaded Source

Built Distributions

polars_xdt-0.14.12-cp38-abi3-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.8+ Windows x86-64

polars_xdt-0.14.12-cp38-abi3-win32.whl (3.4 MB view details)

Uploaded CPython 3.8+ Windows x86

polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.7 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (7.8 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ i686

polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (7.0 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARMv7l

polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.2 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

polars_xdt-0.14.12-cp38-abi3-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_xdt-0.14.12-cp38-abi3-macosx_10_12_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: polars_xdt-0.14.12.tar.gz
  • Upload date:
  • Size: 982.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.5.1

File hashes

Hashes for polars_xdt-0.14.12.tar.gz
Algorithm Hash digest
SHA256 d600e2b74c55616a3cb70b08912b1c91e6894d3c424ed8d2072d775832a1741c
MD5 0ae3d28a0da6b5d932659402ac8130c5
BLAKE2b-256 0bbc4e9a91baef17080b0ebb0f20bfcbd1b1d78b9170e657a963e3af295fe032

See more details on using hashes here.

Provenance

File details

Details for the file polars_xdt-0.14.12-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for polars_xdt-0.14.12-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 842f738b6255de6d0de9755294125106de3e86fc10b2f284de1670168653e30e
MD5 9368a53495c6803aeb01e8cf1d496125
BLAKE2b-256 3a244e190b3a4ff669b8b62f50c94264a41e3042d75dd08690bde74f3cb6489f

See more details on using hashes here.

Provenance

File details

Details for the file polars_xdt-0.14.12-cp38-abi3-win32.whl.

File metadata

File hashes

Hashes for polars_xdt-0.14.12-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 3b80e200fb36d82ecd6847168fc74af81fc6a083d1a13feca742c1bfe1dae506
MD5 dc585e487c9507c6b4afef78d592a142
BLAKE2b-256 fbaaa39e6134f1aabe34e24812584b786c7400271a225fb9d779772a50113ff5

See more details on using hashes here.

Provenance

File details

Details for the file polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cb46301e41d2bf9935b0f3bb22fbf4fcae39130cadef6bc1378acc1b9c6a482c
MD5 96944c3b04649d1f927707e40809ad87
BLAKE2b-256 1d32f8578cecb398953339007b2d0020870e0b733cb3e6d67dc2561141c4ef45

See more details on using hashes here.

Provenance

File details

Details for the file polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 e2dde137718466497fa66941884e60d4ef53a83b09c52f6d8de32dbd834c8162
MD5 3cbadc3ef5ee9149c5b53dbd01238d72
BLAKE2b-256 cc0607337a11e098f176d4181e2a5d05c8d79847227f360f02a1d6cb33f108a5

See more details on using hashes here.

Provenance

File details

Details for the file polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 7efe749688fbdc79f95deb214dad4a8bd926d5b6c98dede0697de09fe75b6a12
MD5 bc01f3ca61031fb77ba4e2f1d61eb83a
BLAKE2b-256 5ce27d5275b46266b5897de89a3ac5faa8fe2ed1b3a270e9dddb486bb0f0c6ef

See more details on using hashes here.

Provenance

File details

Details for the file polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ab351d6cbccad04e32c0899d8833eba1bd0880c00c5ef3b2f2a48bba6e88e13d
MD5 b2b83511a1095546e4f4076a8c193069
BLAKE2b-256 106c6287bae3e6b1aecc4ba4db80b58a865dfffed779e71c7ad9d2c2b1d1d120

See more details on using hashes here.

Provenance

File details

Details for the file polars_xdt-0.14.12-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polars_xdt-0.14.12-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6dff4ef1c09a8e8b6489d21d027e0794c616f2894264f6d3c342d58d0bb3666
MD5 56495046e28b606e311ed1ce4ca48986
BLAKE2b-256 5007c361ef2c6dc715578462e4465340ce7375263e75e1ca9f8c08c50442126b

See more details on using hashes here.

Provenance

File details

Details for the file polars_xdt-0.14.12-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for polars_xdt-0.14.12-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 04a5dfc7ad92c385e0aa552556733d2e1931cdb8efc16239a4d576de08132333
MD5 3d5ff70ae5405908d28b45bc3c212541
BLAKE2b-256 830f4a3381ca9964184c333be13eb59588f5a384e5fa3313aeb9d67826de4d69

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