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

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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8+ Windows x86-64

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

Uploaded CPython 3.8+ Windows x86

polars_xdt-0.14.2-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.2-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.2-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.2-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.2-cp38-abi3-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_xdt-0.14.2-cp38-abi3-macosx_10_12_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for polars_xdt-0.14.2.tar.gz
Algorithm Hash digest
SHA256 bd6ed7b61dfb307398cd930680fb48fee5b1b29be5e22c392bb582b358670d20
MD5 8d0cb60757a98f99f8f5bf000fb1130d
BLAKE2b-256 f1ec2848d695a222a632c9b0ad286b5016360464bff1f4a978ddb4c5b6dfbd42

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2487b41534d757573477945f1ebfd8c453b98bb8a251607817126e4da8866fb5
MD5 fb81c6557a261d2c336f8609ed94bcd1
BLAKE2b-256 7d6d869bfe6821e90d43fb7359b44e979c80f43a62e1dfbf1a7fe4d7d5e9488c

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.2-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 ba3b004cfa36c3907042f24793017e657b541a6709a74dc7154b4bbd04f0c613
MD5 b194d047230d9c8962bb53b694e389e8
BLAKE2b-256 3e4bbee0c0d7af085c40e930bea8fb718dd3567b9188598b4d9d9f6db61cd434

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea8f247b9c74ba33c278bc7948d49ca06797de09eb58466b44cb1e6701c020c5
MD5 8e857ff574d642bd23fcb7d0bd69dce6
BLAKE2b-256 44bfc662a6fddf10070f8a26c1c01cb9ed7113311a8315064beda3ea24833e66

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.2-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 65fcf3205501527543fa5161bced38171b262ea1e3a19641ba0cfad02012dce4
MD5 67d8ed9e84a6502f1095575f11bb4070
BLAKE2b-256 6d8e2adb108aaa109db5bf327a0e3f638a62024565b8de388e28ea1fe2ace13d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.2-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 3a364ba802db099269028bce6592751c73cdb0e05bca10ffcd23670630b84112
MD5 03c09bc5b794a60812a1c50fdcfb2b57
BLAKE2b-256 b35a09e660c0d27caee1ec852b28e8b47b5f96ad550c748d0e738b4cedb9b4eb

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 57120e9c46bdc775cd5896e2897c04cf1f71c0ab04777bd4fbc710be0be6d100
MD5 fc7f98773e7d83bd045be3a76135942e
BLAKE2b-256 0de380cf4cfd9910971c91a0e9a48357274a307517a6554bcf69b825c387e4fc

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f866fe2d2672888fa44272db47837739f2a51052ea4b47d1d66a7db0d4b856de
MD5 f9998d57d490fffbe6bc92023e574525
BLAKE2b-256 69650d2278bd5286033311f2339c78d429db67d33fb2f1494f28c91cdb0e3311

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.2-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dd16f53c32d942d53b88d128f15dd7267aa1ee5b96df4561cc70bc9501ed270d
MD5 6d3ff4138f0d0cc6d661cfc07dd18bfc
BLAKE2b-256 6ec11fbb825f2cc893e34d9e4b646a848675ff03f5ff5faae4679036c7824a0e

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