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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8+ Windows x86-64

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

Uploaded CPython 3.8+ Windows x86

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

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_xdt-0.14.0-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.0.tar.gz.

File metadata

  • Download URL: polars_xdt-0.14.0.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.0.tar.gz
Algorithm Hash digest
SHA256 85ed48ba2e2b914d420e1bd5f8838022338800501d1b856c3acb6bef54f273ad
MD5 b87d1d0800df74b4342cf4c675e0deb0
BLAKE2b-256 fa47088e9019952440a67efff4ead899fbd8d21f4a5e064ec9be077b7b588f8e

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 61cda79a702face4947fd9c3282b3936f37007debae0b28bf45f30492cfebd6e
MD5 07e2c0a76258e1d71312dac865d5cfbc
BLAKE2b-256 20bb7d2c03b280be301123aae52cca45b469611e39b5f0d7472d1d18d10a3e76

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.0-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 ed81323ca4f1c4f474ec233338b6c5a508b8e6b92b344951d0e15e47aaa62fe3
MD5 c2059669b9585cbcf8e16ce3781f6d96
BLAKE2b-256 c2032e83de33bb9520c7f3b848e98c3ef876aa17f19f07e6b1220f149df10ae3

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1e614c8facef9ab402c50d0f927c0d8349161e0f46ed6d32ccbff8e68fafe913
MD5 bd0b7f5ee73b50f8a1e66e88d681ee6a
BLAKE2b-256 617fd9e9c97b8ed5f00512c488de799fbf910b1a4906e590995eab56955049fb

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 03c301a0e1055d0e5e7bb25fa5cdca9498af99f0aa015f45b401fc3a6fe71a38
MD5 4c6aa4a34f5edc2bf34163dcea6948f9
BLAKE2b-256 b4652ad49b1c6072998d1b9a3f80ca3058a8cfa5e6b151fddb569f15e1ea7773

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 38de5c6480bf083c3900fa97b377ca7606b0563663cc12c45936492ee698347b
MD5 afda974c96aac5c8e4a790498855a64f
BLAKE2b-256 065fbcc691b04e5aab973b333ca332df4126a293fc22581229bb30af74ffb5a5

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0eb9a5939107d0da068257eda0a273fbffcefb522a2fb3ce2ef640eef0fe52b2
MD5 af5f21e80ebfc3263fe92410dbc1f2e6
BLAKE2b-256 61fbf7c2b7a7eae926cf65d093ed069e509148223a6e71bd68856fa82a94cfae

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b2269f66f9575f91334bf8367c6b7685c1214698f3a1543ba7254ac0e7bc59de
MD5 8984180d8899875be543aa02999132f8
BLAKE2b-256 87feb8859055a2889dff085c25d4315dc801150e7455cf2451d51bbd30cd9483

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4266adb451e0e3782b8c2b83de1559a747d8b7027b48065418e5b415e4cf8984
MD5 9691f20cf8ffc5d55a76a6ed7b50eb9d
BLAKE2b-256 34d665d58b162718f714417176e953ccdc15d29407ad0c3d99423d9130ad207b

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