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
  • ✅ convert to and from multiple time zones
  • ✅ format datetime in different locales
  • ✅ convert to Julian Dates
  • time-based EWMA (upstreamed to Polars itself)
  • custom business-day arithmetic (upstreamed to Polars itself)

Installation

First, you need to install Polars.

Then, you'll need to install polars-xdt:

pip install polars-xdt

Read the documentation for a more examples and functionality.

Basic Example

Say we start with

from datetime import datetime

import polars as pl
import polars_xdt as xdt

df = pl.DataFrame(
    {
        "local_dt": [
            datetime(2020, 10, 10, 1),
            datetime(2020, 10, 10, 2),
            datetime(2020, 10, 9, 20),
        ],
        "timezone": [
            "Europe/London",
            "Africa/Kigali",
            "America/New_York",
        ],
    }
)

Let's localize each datetime to the given timezone and convert to UTC, all in one step:

result = df.with_columns(
    xdt.from_local_datetime(
        "local_dt", pl.col("timezone"), "UTC"
    ).alias("date")
)
print(result)
shape: (3, 3)
┌─────────────────────┬──────────────────┬─────────────────────────┐
│ local_dt            ┆ timezone         ┆ date                    │
│ ---                 ┆ ---              ┆ ---                     │
│ datetime[μs]        ┆ str              ┆ datetime[μs, UTC]       │
╞═════════════════════╪══════════════════╪═════════════════════════╡
│ 2020-10-10 01:00:00 ┆ Europe/London    ┆ 2020-10-10 00:00:00 UTC │
│ 2020-10-10 02:00:00 ┆ Africa/Kigali    ┆ 2020-10-10 00:00:00 UTC │
│ 2020-10-09 20:00:00 ┆ America/New_York ┆ 2020-10-10 00:00:00 UTC │
└─────────────────────┴──────────────────┴─────────────────────────┘

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

Uploaded Source

Built Distributions

polars_xdt-0.16.8-cp39-abi3-win_amd64.whl (4.6 MB view details)

Uploaded CPython 3.9+ Windows x86-64

polars_xdt-0.16.8-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.6 MB view details)

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

polars_xdt-0.16.8-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.9+ manylinux: glibc 2.17+ ARM64

polars_xdt-0.16.8-cp39-abi3-macosx_11_0_arm64.whl (4.5 MB view details)

Uploaded CPython 3.9+ macOS 11.0+ ARM64

polars_xdt-0.16.8-cp39-abi3-macosx_10_12_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.9+ macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for polars_xdt-0.16.8.tar.gz
Algorithm Hash digest
SHA256 452dfa527b433b0ca46d649d38ddf9000948489042886b0cb804ca26a69e0e79
MD5 881a868c3f29911be21de1c4a483c836
BLAKE2b-256 19e453dfb674ec9a30d093bfffb1968d5465a606fc79d33e29f1206354a52f00

See more details on using hashes here.

File details

Details for the file polars_xdt-0.16.8-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for polars_xdt-0.16.8-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 263dbd317d58e78670cd836bde0edb4c118c153b28de617a3db17328c3ffb681
MD5 0301868ddf6ff3cb5fcf5c4cd3f5cd77
BLAKE2b-256 0a22d37210e4b9c612ee976fe60e45ebc324a75507712f864994397c1509e42d

See more details on using hashes here.

File details

Details for the file polars_xdt-0.16.8-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_xdt-0.16.8-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4f1c763c177b8450594873398834cbe6a797f4cac5fee9c5cdbf829c6301a8f0
MD5 f0a26a7348f156d0e0704d8ce6a0032e
BLAKE2b-256 a9ae930e2266cbba87914887b2be3493b8e63d902ee658b62ef698a792f2c2af

See more details on using hashes here.

File details

Details for the file polars_xdt-0.16.8-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for polars_xdt-0.16.8-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 40679decbc38126ea050d2520fac892356a3c5db773cd6f07c7b1c19f9660302
MD5 58dd0325fbb15fc2eff19e404ebb5d82
BLAKE2b-256 d96f290a9668a4a44c5e035ba1082eaefb59d7e069921d4a0768394e8b15b496

See more details on using hashes here.

File details

Details for the file polars_xdt-0.16.8-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polars_xdt-0.16.8-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a571e20f75f86f41e7840c33276ca02606e68f9cab8d27937bbf76a8060ffab
MD5 d107a8a7041273c5855a11a87013055b
BLAKE2b-256 a60686804f82f16acd4050de0a0b65d17cc05285e4cd4ff8fca5b6eabc91921c

See more details on using hashes here.

File details

Details for the file polars_xdt-0.16.8-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for polars_xdt-0.16.8-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6b1c4ec89779769052bb6752479627bdf1cdcae8fad9267bcee647c0d3f6229a
MD5 d0b5e28b0a75d0764b00650aa931e53c
BLAKE2b-256 4625e83a3dd2c91fcfbd4665fe51f87065f12c8c6fc62b3010b01947c99433e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page