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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8+ Windows x86-64

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

Uploaded CPython 3.8+ Windows x86

polars_xdt-0.12.7-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.7-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.7-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.7-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.7-cp38-abi3-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

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

File metadata

  • Download URL: polars_xdt-0.12.7.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.7.tar.gz
Algorithm Hash digest
SHA256 ba1584285ff6d47e547619b0ef9557b6b2b7134a17dcd7fbdc886782839723d2
MD5 c8b573e8225c088eeaaa73ffd54c5f95
BLAKE2b-256 652d9fabe3e7cf8141b9facbf6d3d501685ab51085eb3d700731ff7c3a5f4ba8

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.7-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 84ddbf07652cdcc2e3993dd02e42a7afe4bd48edecbf575def3844913bb76706
MD5 1b5d1c9adf601eb433cac2aae62fa492
BLAKE2b-256 1ea3963997515bafe991f46193cc47c9f0c8a73292ef7aa6b019643a6f89b6e6

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.7-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 a91258fd4e2a2d473536822cff2492e47f495fb9fb36f91ed2a44627324ca3ff
MD5 427bb18f447393f27556761fae91f9d4
BLAKE2b-256 ed1149712d51b23a6664be9b1c9eeb208e55729e7e9e24651e08b1d76f1b8d7a

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.7-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c596dbf647dd9f9e6a0b1108d68d429b3e2852eeed7b9ee9fefda89f7b64ead7
MD5 a486eb1f3230835b71082eccd4846b60
BLAKE2b-256 bf067b36f1ee192fcf11073838399574449c8c379c0267afbb0f86473cd4effd

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.7-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 9002ce6dcc09ff2d95d6f8e77cb76c94488af0dfb7d047fa94eae80de5beb7a4
MD5 cb1713bc5a014a2eeb2eff60a424864c
BLAKE2b-256 477a79438f7775b009aeab062e9ccf75a4d19291ba39208bd6e033caed444ed3

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.7-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 63f838105c2397dfb2e4953414d6797e53b023d4595a9a7e0b159fd086590c2f
MD5 c875fb84b99aa4508bc90733770b426e
BLAKE2b-256 574aa982130439668a2db210758bde89e49bbdf97efcf11d7a7c3f43676360c2

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.7-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 69e72fe3650db50a070b2339df442be0268d3bb76cc475ef43738a84b083b12b
MD5 20c06355174120c9173946c2adc1f392
BLAKE2b-256 12b10e4bf41019540c979d9add55dd824b43e26cc7625a4175cbebb0e8c1ad29

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.7-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e5757fc4edbda4db6146de2d02ce3bb7a3ae056fd2f2519dda5a8e15c6a3918
MD5 e5807baf30282e2c655de6ce64f3724c
BLAKE2b-256 d2031813a0f635ef07fa5d768b28387583c053b13dd1fbcfae204198843a8f1c

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.12.7-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 209278670d34aca3c9342cdcd6e48e72ff7b7e5cd0c0ed8842356d0a7d80c153
MD5 47345b6c3aadb2e973ab280556a73471
BLAKE2b-256 1ee0e604129d993d97edeb0bbe25bdaa5662f23c1cabc3299717a3c94586224c

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