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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8+ Windows x86-64

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

Uploaded CPython 3.8+ Windows x86

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

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_xdt-0.14.3-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.3.tar.gz.

File metadata

  • Download URL: polars_xdt-0.14.3.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.3.tar.gz
Algorithm Hash digest
SHA256 d039f9861669673d74385a8e9af1cf1f90a7e17e32a1728926ca152bbdc228c8
MD5 1c33610e5fc7f6fcb11641dea90003cf
BLAKE2b-256 a8bbfdf95d37083fd021a45f8194d6416f88231566b52da434c582e093bc5b88

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.3-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5f39f59acf043bb2c2cdbcc7041fc75be3e22886295c0a6fb7d234ee226826f6
MD5 2a736fa4002b2f53f8ffb39b20083bc9
BLAKE2b-256 62417f46829cc77bf6c906a87dfbff343736577c9574f602a4cdaaf08ec84e39

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.3-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 9d71b8f0f5448590cc5c6d7a6aece56686774d41028c447e2b7d6c5a90ed474e
MD5 c9dac435a10a05d361570a58b78291b2
BLAKE2b-256 1411ba3901559d2441bef7a50703c46da5dc1a0eba26c16fa7ea020f83783516

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ba8e98a6d813b625e4b384d73e9de4c82750775bfdfcf63f6cefb8bac6aa81b0
MD5 0bbf9926bce22783bfe34e00f7455d0a
BLAKE2b-256 2b09b13951160c41187d490d3b308d22029b89576c6c0e25090f8cd7e527ad34

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.3-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 f25ac02a65a05d1f2b1eae816548c1917700e4db4be32befff0f61e5858f3b7e
MD5 aa23aab8a701324d508b1f7d1e230d3c
BLAKE2b-256 390262fcfafcdb0fc7f4a35f4d7d70f64286ffdcb3459dc982f9bf45f811613e

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.3-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 b583e6a02dd9681dc2fec3c76deb20f525b55c14479bfcc0ef85cc0b15a7fc05
MD5 4b0f4af728737fea50929709d62ce0f9
BLAKE2b-256 47867cb90cc0a44fe372c65aa9566a4aa84972348bed93b8efc36c4db7bfa8b3

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d710e7bb09aaf595d66ff6a598c673074ce4ee03be5f624f9dc2e3fae3983b24
MD5 6aebc129083ef70ebebf09ff1786c6b1
BLAKE2b-256 da8d81fcd9446f8730fec4c343f1dc32b9a775e25a084fd157e68e2f21f1e26e

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.3-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c51fdf55176edb277baea6c697176fb153ffd6ce0009cde398d795693915549
MD5 426c09945a70409e7166c859e0370f2f
BLAKE2b-256 0667b3d08d284105c4fff588b95a9e420687c695cb197a4e0bf4161fa437ca9c

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.3-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b9742b4e123f0feee8b5614f95c5c70fe4ccff6026f572f212ac2ff316ee4f26
MD5 66f1958d5f5a6aadbca2c82298cb59a2
BLAKE2b-256 cbd87f5412d8b7b92dce6f6189db8b5fa7d38696aaa8f48400b60500bed59b7a

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