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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8+ Windows x86-64

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

Uploaded CPython 3.8+ Windows x86

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

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_xdt-0.14.1-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.1.tar.gz.

File metadata

  • Download URL: polars_xdt-0.14.1.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.1.tar.gz
Algorithm Hash digest
SHA256 bf2e20830fa5ca79ab459f2126fabe7d78218a16a7c63e63e941a083dc8c08be
MD5 59b8357259925ec7df15fd0c051a52aa
BLAKE2b-256 c882659087d6cfbf79ecc22cc61894ae87e14d1e34ac2335f00418fe0bda2e69

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1b46ff12b4789a2aab4cbe8a2428e824c87f4f57004cbb112c2abb663b6b3275
MD5 372724ac763d281eea8f2f2fbcd6bd05
BLAKE2b-256 744f92788651c3f7c1f02edf257517fe80ddc69fd7d5ad3265168fe56bca0f02

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.1-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 08254034ea70d8da9c4f7c15b9383b02f324db63febe5107a3d56f7f4603ea83
MD5 2ab534ef48301c05eaef52a19b2b5c52
BLAKE2b-256 c12bc8a7f1c19124c0cbf2eb386fbe940c1e3de75abad6598b7d0574d4a55b8b

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ed026a708ac2e4389c9bd9a2d65cc59398a1cb60bab79a00daddda5a05004ef
MD5 51043e742746945131b01bd5b1995d67
BLAKE2b-256 7592f36b57d43e2773f503b6bc77d26211e27c4f486f88f7b008d9c8e6bf2d1d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.1-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 c16cd322848427c93170174a98792282ed74e4420c7fcc12fe5294fb645b12ab
MD5 240e71604322bf29b97144c6b1523ca6
BLAKE2b-256 4dadd037f75d3533a77d51d00554ed425e2c4ca0f509b79c05bedc57689af26b

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 ea4ed2b2e081eee20957026b552ee33844043999ca8de7702bfad77af1b5d8e3
MD5 fff9efe7abf22aa4a005c32b8522c185
BLAKE2b-256 ce7a56129360f72895e5bd38eec14d4b8816e02b87f27aac2a4d8a1eb962018b

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 95512bb29b57a99a2681596990fe5123960935f68cf115abca0ea9b26e17cc83
MD5 e99077726f8a7a4ef499e7db480bcfca
BLAKE2b-256 13c7044dd4d93d9b6b0b5ed6efb74719f583966f67cb26ffbc50d20f109b2481

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 62711cc908ea838bdbe49f1a8ddeb16cafab17e5529d148e90dea6397e6baa18
MD5 2142869a9e1bf926eb1dfcea83e7e3d2
BLAKE2b-256 b4832733819b38454e1027ecff9d05a7e94e7d34f3c3a6696f469c61b542c6a0

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c0dfdcd25ba8a58ee4551f8cace898b7643e5173eb2d43a59547c676e2cf92c7
MD5 445e51de2d6a22583523e3383e2980ad
BLAKE2b-256 286216a560076f3b7635433751a329c594ac14510deb5f93c493a722f1d6defb

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