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

Uploaded Source

Built Distributions

polars_xdt-0.12.8-cp38-abi3-win_amd64.whl (3.7 MB view details)

Uploaded CPython 3.8+ Windows x86-64

polars_xdt-0.12.8-cp38-abi3-win32.whl (3.2 MB view details)

Uploaded CPython 3.8+ Windows x86

polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.5 MB view details)

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

polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (7.6 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ i686

polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (6.8 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARMv7l

polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.0 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

polars_xdt-0.12.8-cp38-abi3-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_xdt-0.12.8-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.12.8.tar.gz.

File metadata

  • Download URL: polars_xdt-0.12.8.tar.gz
  • Upload date:
  • Size: 976.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.4.0

File hashes

Hashes for polars_xdt-0.12.8.tar.gz
Algorithm Hash digest
SHA256 6c0b886cc4e26006a90adfe85bdb5f0001876d6828577a352d669fb308c93e39
MD5 c3cba39ef9a08cc8bab419b55b3d8412
BLAKE2b-256 61eef49d53635055c37078a793dfd2247e5778d40b88dd0b761c3bdffc5d4dd6

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.8-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 fab3f37090e0b035c05268194c57221bffbce894225db01ba479a42ef256e57b
MD5 fd486ff5413905ddce438a44c713fd73
BLAKE2b-256 f02f24b4efda9d73c456fd39154b68b6abfaa4cb51ecb45b9bda8f95c68fdbbe

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.8-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 184ab1a1b5c3d156beb23c6187dd42995c686b2b89fc1f5c506feffc5f68dddc
MD5 8611bf893e5b4d6c5189e638ebbce3bb
BLAKE2b-256 2f27375e2f97835acd91f8671257a6aabd842fd435a0a804ccc909d61bb1dbaf

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c05d5ef560c8fd8e796bc24c95ed5aacc92a358c89c404f25a29459fde8f9428
MD5 a1336b14ed332c7134a76ab01c49316b
BLAKE2b-256 bb33701627c11b16d9a2dcf918a4f477ef969733716acc25b09040491c1dd5a1

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 09d0b6ac8c5dd771351e563b074f2443913799d35225c3f4cfa155dae49b70ea
MD5 2ac95380f6032f31c77fca9eecff05ff
BLAKE2b-256 7d0c86233682d5c428d4a5af2c1b248a3ffa6d1705b0031dba10f3d7decd479a

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 9963e09cd7254c438e049d1eae36a0c13510f6b9ea8ec77d831e47af6b200aae
MD5 a02bd4322c37ab91461f7f5c91e030ea
BLAKE2b-256 15e76f857cff6936f5a312fa840b62e96d81bcb02348d51f554f34b13e430fdb

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c9c06f48f0ff930fb906f336d332994d8519cd4a09bd42b0dfe73e5ed19e2e4f
MD5 4ef3057494c3c452192bd3682b126140
BLAKE2b-256 82f326b9ad005fad60d0c00feee2205d5bcc0af08025126d66729edb2ce4c4c5

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.8-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 34be6224e706bad5de4690fd88ec5a727a1bcd789d22d2dd5167f83e73cf48cf
MD5 69beebd7b3a4952175d19290bb5d1ccb
BLAKE2b-256 df3cc9d375ed901d1e4ae197d1e3c3ededd5031906e3b6f2475209843b65864b

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.8-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3c2a697f7e0dc53b987d3bf1f8d2b83b4bf9c4bc4d454d92928a92183dda9c09
MD5 270eb6b993b669b910c62f16aff2cfaa
BLAKE2b-256 2df7a2cdc8ef95b498d1c008e3c6a6b0fb0f9be9f2f1804b053aaf8aba7fbf2a

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