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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8+ Windows x86-64

polars_xdt-0.14.11-cp38-abi3-win32.whl (3.4 MB view details)

Uploaded CPython 3.8+ Windows x86

polars_xdt-0.14.11-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.7 MB view details)

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

polars_xdt-0.14.11-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (7.8 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ i686

polars_xdt-0.14.11-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.11-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.2 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

polars_xdt-0.14.11-cp38-abi3-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_xdt-0.14.11-cp38-abi3-macosx_10_12_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for polars_xdt-0.14.11.tar.gz
Algorithm Hash digest
SHA256 40d34c87abcb6763a14a55b7a3741d12c2a795e00d04e491736d057a64392468
MD5 af2891f09ec63450243601bcf5eff2aa
BLAKE2b-256 1657eac83484cf2580094a634be7c70116bc59ff0a4e81000cd51897ae2a9198

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.11-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 222ec074c9f1c0731e9f14a1e97030d2688c92dcf58e8432c89b08cf29fba493
MD5 b5afd5bb749e0761ca970ad75dda57e6
BLAKE2b-256 274ed51818b5d6241d9c1584c18d38628e66943b25ca3c6df7cc4e053c4ef881

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.11-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 0b5fcda34261b1dbfa9edac81a14a59205555442cbfb304c7b51afb299cbbfd2
MD5 1c75c984be1b66e25eff7c478f92739b
BLAKE2b-256 4da9aae98e4874ef59e6812dc5fb309a73a2e4198ec2e37a68503cd4bf9a1d28

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.11-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 391600e63377a9926cd848ffb094cd0d1767c8c0d16bbf42f7023fa969e5fe06
MD5 cde0c9080905f7496585b63987905203
BLAKE2b-256 5d5ea09370aaf63e75ebb371068a159141c03ebb32c536e690082ee8cfec2dfc

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.11-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 611f8049381119c9bee8c6d93eee53224b2e114019b0b652796b229b5242c018
MD5 c8795c482e0b935f0b173bad25578826
BLAKE2b-256 d79cadbcec57954bcaba8a3fd0156e4fe1857c50bb6adde9a0d260670cab147a

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.11-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 3a58851e35c209ddaeba049efeda72c4afe6e0d6f1aac524a873aafe7da61f20
MD5 925222d06391da5db4099e1d0312d031
BLAKE2b-256 572e3f1e0166ee1c0d173f3246444d06eeaa41a28fc22ef9e16e8cb619d4700d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.11-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ba1bb39216eb64970b2edc0605bb82d3072e3c8ac1f190a7325b692d6c915a07
MD5 585682fcd42509cc20c593db7fdd4662
BLAKE2b-256 f95c4bcd194c0d7ca3aa4b4e4a0f164551706f81efb96b324a3679f4346b7964

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.11-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 07c2b8c3ca97bfa37866445f54915c7a9ef88346a2728f87b5772d9d6a5c06bf
MD5 508ad2d62041114be00f64711a87a221
BLAKE2b-256 f72056e31637e5b899b3d3ea5b8ac6f2703e060a41d298c29bf13af2dd01df00

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.11-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 29665510911e165b0e037bcc5a07ce9d50060213706f33a9d31b369ff01acb95
MD5 0d26fb3030a7c7e8c1d330e239ba7795
BLAKE2b-256 d8897dc056d2cbca18bfa557e539a554e2624ca4a720d0407fb7d4b825002b37

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