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

Uploaded Source

Built Distributions

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

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

Uploaded CPython 3.8+Windows x86-64

polars_xdt-0.14.6-cp38-abi3-win32.whl (3.3 MB view details)

Uploaded CPython 3.8+Windows x86

polars_xdt-0.14.6-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.6 MB view details)

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

polars_xdt-0.14.6-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (7.7 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ i686

polars_xdt-0.14.6-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (6.9 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARMv7l

polars_xdt-0.14.6-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.1 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

polars_xdt-0.14.6-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.6.tar.gz.

File metadata

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

File hashes

Hashes for polars_xdt-0.14.6.tar.gz
Algorithm Hash digest
SHA256 226846bc4d76f5783ef6c47b261d512a6e9240ffec41dc3180c1dd234cff06de
MD5 d2ffaabfaee93d23b652eff037bc90b8
BLAKE2b-256 88e79ab853c151a34d837ea4c5fba8d05b58e9a894a7cfd1190b77ca2e8cf926

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.6-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 793ce7481d5743cde56950f10ff67eeb0b864e59959203b659236e579e4e6d39
MD5 f501ec33b359004aa0a9f17c4c1acd7e
BLAKE2b-256 dce89c608236cb15212be0cc9fcddb29bb8c918a244486f78e2077f8282cd80f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: polars_xdt-0.14.6-cp38-abi3-win32.whl
  • Upload date:
  • Size: 3.3 MB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.5.0

File hashes

Hashes for polars_xdt-0.14.6-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 a8ff361e4291d5faede5761b83c16716cab14b53a117ae312182a23e6269ee2b
MD5 e1d129ede39bf84342a00c66952d2922
BLAKE2b-256 b92ac77580506cabb657dd422793ce31b615f2777c6eb5948f23e46fe683d74a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.6-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f3ee8daae3cdc8d147310c2c04203306d604cb700f768e93dccd347a03c8b99c
MD5 d302691ba06dd21071414dde2745137d
BLAKE2b-256 3c26cbed1ad56bb6c50776e5ac355b77d818f3e2f538392208d5436985ccf02b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.6-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 173a858b7577412a2adf392daeff6b002de013ab14248e9ff9ac767dd5836676
MD5 2c1107bf5dbba17695c1fb9d5eb6cb07
BLAKE2b-256 e0edfd9eda48aef4dec75ec3808b42cd69a4c91febd603bb07f546adfd36e521

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.6-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 fddb886281756741e7023a4fd77780c3de04df7d3125b61476cd650dc171ace8
MD5 9e4851ac8f053dcb499e46c15f236eed
BLAKE2b-256 b382e3b5ff815616c6a89fa88d06fbd035e0d845d1c26b92e175ca2be88b4402

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.6-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 635c13b9d40b650a95be25cd69ce55c9bc9bc2ef94854234b20322c08629301b
MD5 7c1f228797f54ac9562ec75382197369
BLAKE2b-256 8193d5855421195fbe96d1a1b0090bea397c08234d9df1db0db708453b6116bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.6-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 545fa246a56a765ccda4dd8b6622b51c42ecfd18a558831cb465c8444406a89a
MD5 af6b686faa2e5b30819fead4f72a6ce1
BLAKE2b-256 7d735cb33fe226a214a81491f3a2bd7e2b0531b65cbfc1f7cf858d8cb36ba54f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.6-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ad1fee3dbb9a181028ad35d741e214e1f585f1d98a249b49118222f780d30a55
MD5 7339af0a53c18324655b658df0d92429
BLAKE2b-256 4db4a0211e24df49227f9bce8aabf7dd0202a6c466d355a50bd4cdff103372de

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