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

Uploaded Source

Built Distributions

polars_xdt-0.14.14-cp38-abi3-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.8+ Windows x86-64

polars_xdt-0.14.14-cp38-abi3-win32.whl (3.8 MB view details)

Uploaded CPython 3.8+ Windows x86

polars_xdt-0.14.14-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.0 MB view details)

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

polars_xdt-0.14.14-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (8.1 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ i686

polars_xdt-0.14.14-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (7.2 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARMv7l

polars_xdt-0.14.14-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.4 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

polars_xdt-0.14.14-cp38-abi3-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_xdt-0.14.14-cp38-abi3-macosx_10_12_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for polars_xdt-0.14.14.tar.gz
Algorithm Hash digest
SHA256 ce94e4cb5a1e5a1f5077e8b647f85b4da5ab3930b24263e9ddede1e6e3f870b3
MD5 1f77f03ef8cac26e4d8961195069f04d
BLAKE2b-256 5ec15739c6c62743264e032eb481775680742d0e30c7ef371490e07468b954d6

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.14-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c091205e17ddbc097b36520511193753de59e85fe0ae4e227956d83a1344df8e
MD5 5781c86106aa318d9af891cab276d8f1
BLAKE2b-256 41aeea1f5da6800652ad8318f9a0d8c6eb5a2e83ab93e2ed3b3ec3127f317a07

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.14-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 9ab28fb73e10bb394a11f1a5ce0a6131032ba724cf2b42533a531ee8eb3ea74e
MD5 fa2038c8e566f25d2df1125257bcd078
BLAKE2b-256 1945ae2e0c8e7361b871402313a56f56bbae53fbd11dbb2924f15cc93793fd5e

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.14-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 07bcd98e627db7d1670defb994aa16f92c6419ffb1ddcd1eb148aba0bcc16ff3
MD5 1d191d39757377f68d2e2241359b5ce2
BLAKE2b-256 54f9141f7ad905ac7ee9021ec41bedca880ebd960d3634c3abd40c3324b8e28c

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.14-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 dd978e97cc374c32c05d7e733171d43837cf32178c7c77b839b49a2d6b945575
MD5 2a117145bec7ceb5ebf34af5b69d82a6
BLAKE2b-256 6e2b52b036a0a0ed1256aeaea3d8ff3ae4fa7bedc6dd53dd4f2f9aa061df55cf

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.14-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 b80f64e36e0d1367ad0185601d79600bd8a6c1183d04f45df06aa072ce728334
MD5 5d9c499a933b5ee9dee4705d883cd77d
BLAKE2b-256 e54addbc9585ab3096d300d372db97d57e7809cdc986d46ce23692fe428e4cee

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.14-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 594570060a6f39f51dba43384debeb480dc403fd468d9e826318936eb8d8f1dc
MD5 ff6bfddffe422ef2061c248a60f54904
BLAKE2b-256 e22794488bf0c071d2a2450e07c2cc80d64feccb79b7c92b787c3176349b4dbf

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.14-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 92f10f47cafab286d6177088faeec945d96d99b1bdd56287b2cf7a0c820d1f54
MD5 57c2a51b2f092700d5cbcfb4d3f6cf95
BLAKE2b-256 f368272cae9e2b986dddb4d244de6844446874816e5103cc333772c44ffe3a8a

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.14-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5c13e6bf0033d13418615d3c0bce62c761056ac550d46dad71e4b1030af2b45d
MD5 f965b742e7be08b54afbe0e2edc437db
BLAKE2b-256 49cf261b9824b780f1c0be7ef471bdb980219672d51d7b5db53b4de34683d53e

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