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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8+ Windows x86-64

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

Uploaded CPython 3.8+ Windows x86

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

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_xdt-0.14.5-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.5.tar.gz.

File metadata

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

File hashes

Hashes for polars_xdt-0.14.5.tar.gz
Algorithm Hash digest
SHA256 63f8fe30af6c25efaa4a8730a986497ac03f15827031e051ef651b0ed4117321
MD5 6c706c11bb04faa8ea8917857c164623
BLAKE2b-256 3e0c1a6caf63e4fcdb5a402c4186fab8963c2bbfe8937f47cf61a392f3ab059d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.5-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4694f185b58c305d79dde2e586c18a3656390d19d8eae3b3d59f89bdbb9729eb
MD5 59e774788e5cfbf153b1235963572174
BLAKE2b-256 2203ed334cfbeaabaa1d037fc2262c74833353cae773afc1180615596c0828d5

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.5-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 12b3d95568d1c2ee1a19f9878ec2c36eb34a10c4a620b892473795b8738414c3
MD5 bda50a88e705e44cbc4cfd559c586214
BLAKE2b-256 3a43cb839882a45c36391d7991f7dc77e423a592c723dbcf0c354150051a47db

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 70d8ca7b59320a729cd185c8841e9815e1d30e2808c4397f9f3541c89625a422
MD5 f9801c4c59dcaa6417d3a19aeb3e47d1
BLAKE2b-256 df9d866f4a710c3dfa5dae631aa2f8e5f024dc7ee9e5e609464528dd4498f532

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.5-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 1d7dd58d087b10124f57c0fdbd72e1608854bdabf89331cd66dc6931c573aae6
MD5 6c0fbda8c523eda34839673eef794a32
BLAKE2b-256 a4f6b20d91166e916bd7dc7aa94a04456b9a14014682853b9abdf68971dbbbb4

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.5-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 f35de924eed854e1dff29b02e53db287cb6472f49f7f153ae6326012fcb765d8
MD5 03fb04337d7015bd9711879671ba1394
BLAKE2b-256 3cae696b9c56f0f65c31d41bf5aced14470665689142720f22a80b715ad83bf6

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.5-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a3add1ebca489e1acbb8f1d6d3797c85ad7949dfa239bd20b2824cda28eebf62
MD5 b770b277a790dc2dfc2d3ec69d3c5c17
BLAKE2b-256 6353debf132605f8a5f887b299fc54dd30501c93a02749749757037210562ea3

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.5-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b3f225327babb5b95f5fd48b9e8320cbb93106c314fb81a110bbd02eee19744d
MD5 e4a325a59e3eb94b74721f381cfb9b97
BLAKE2b-256 012899a7ae46a354306d3cb98bb064dff08855b192eab4b6c3066915f2d192a0

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.5-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 efb1998f03fde68b585f9f19ece1bfdfc94dbadaffbe0e3b1bc6bd48047fd5c9
MD5 65e6953c240a60fd83dec39ec4da7abb
BLAKE2b-256 426dd55d9f56a540ed606746328bfcb1d61a4c70151fa12fdc49e559fe9905af

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