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

Uploaded Source

Built Distributions

polars_xdt-0.14.13-cp38-abi3-win_amd64.whl (4.2 MB view details)

Uploaded CPython 3.8+ Windows x86-64

polars_xdt-0.14.13-cp38-abi3-win32.whl (3.8 MB view details)

Uploaded CPython 3.8+ Windows x86

polars_xdt-0.14.13-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.0 MB view details)

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

polars_xdt-0.14.13-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (8.1 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ i686

polars_xdt-0.14.13-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (7.2 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARMv7l

polars_xdt-0.14.13-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.4 MB view details)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ ARM64

polars_xdt-0.14.13-cp38-abi3-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_xdt-0.14.13-cp38-abi3-macosx_10_12_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for polars_xdt-0.14.13.tar.gz
Algorithm Hash digest
SHA256 202070462e2db81033223138726bf077d60ee6a51d4bcb78a9ab90c48b3d5e1e
MD5 6fd4324aac4f623802b173ca6abd1aa1
BLAKE2b-256 c78810650e5ce5cb1385c0ebdfc8fe13966c21eac94966984771627d5aa016cb

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.13-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 39ec0afa3a2613f500507daecb7c6c65c994ecc885dd714b02d23819549a7a6c
MD5 d5b83936923b3d997656e2ae4a8d5c96
BLAKE2b-256 cd5bf567726110292ee0d05c3eba927d93524a3b3330c904c25def97d3aa2f12

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.13-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 b270e93068bc741cba46be07ad38a0cf0a35e336d692e789dba1aca38771c4c3
MD5 a866462d65e67b2a4c803c3d5cc4cf9a
BLAKE2b-256 88d7fc17e770cbc6b312ace276e3e1aacc23ed6d40e77311cbf06036a4dc61b4

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.13-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0611ab7ab0a4a1766176b13dd82ccd79e04c8059d52088fc37e7a6b9579a7374
MD5 158e511ea2d93aa0aa9129057f89ea1a
BLAKE2b-256 a0d859a76ad98635ab139729056b7845ecc5224408bd4c918c61ed8676dff659

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.13-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 2de4cdc56cdf8cd36d836e04d0a90a406ef04a26c5c1313a2be2fdcf1f33c0ff
MD5 3beab2af1287056982c4c14cbdf795a2
BLAKE2b-256 fe5d862592d1457b857723568de0bc7433a9dee7ffdf7f6cb9c847fde2767202

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.13-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 724d1c1cbf77773326360cdb7d160017913c02a11abacd933ae6c2a8130c23d7
MD5 ad87411abc2eca9b4d1ab9e3902609fa
BLAKE2b-256 03bea7a02a97324c6bfd7e2969283adce3ac6f7dd339fa4d99f2dc92d8f7e414

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.13-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8668e53752d66ef48898c5b187cbe0791d16f4a08ae56220c2933e5b2877bf09
MD5 f8b99c385bff0a4cb61b48a1ad5999fa
BLAKE2b-256 c7f55f161019eced7376773e3dbb1684d9d63bd2cedf42bc9f664604e7a013b5

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.13-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 401a4883072131fc2369a1f122cdd98cd239b54d1cb8a22cde43ea1cbebee05d
MD5 95f44bc661e196f3e7b8acf50e4c75f7
BLAKE2b-256 8c39bd4f8056cbc3ca3c14eaa7c8763fada640db3fe22a8443de76bd0475d6a4

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.14.13-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fc5cfb1474e3226f7626be60a716bf850c577da35addc1fa41dc22d8f7dc41cd
MD5 105dc25b63fbaa89e66b033a1c6ae1c3
BLAKE2b-256 fe02efd6ea7a663610807808ff6a1463b7e70e0e46cdb10647bf61d4c83beeab

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