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

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

polars_xdt-0.17.1-cp39-abi3-win_amd64.whl (5.7 MB view details)

Uploaded CPython 3.9+Windows x86-64

polars_xdt-0.17.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.8 MB view details)

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

polars_xdt-0.17.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

polars_xdt-0.17.1-cp39-abi3-macosx_11_0_arm64.whl (5.6 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

polars_xdt-0.17.1-cp39-abi3-macosx_10_12_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for polars_xdt-0.17.1.tar.gz
Algorithm Hash digest
SHA256 3a3860bf3c3015d519192102af4de687feabc6dbf6a038fc2f60cde72e9d0c45
MD5 52862ddcc89df6a9d2f74d6b4be7186d
BLAKE2b-256 5dfc5aecdaf5d20a84e9e9daae4a41b9d8f06062467fedb4cdb609d32bcaeee3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.17.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a4c68e949e795df57b97ea787638920285553264745661e9506c19a0059811de
MD5 60af7eb53ef651a2869e83410f2ddc21
BLAKE2b-256 d5f14f28e5d890dbebd83f1be960bb64a6dcb99e635d8c796bb04fa597a45711

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.17.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8bae8fbf6a4e10fcddd62e0e28ad667b56ecd53d3b6228517a8c72ac384dd233
MD5 c1ba7c196a2032f5d6379ce7c5abf220
BLAKE2b-256 14336e461ae16b55b580f75f4090cada72818f3c38e89a3ae28045660e16c207

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.17.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8aeadda0f9052588f226fc24df00e97fbadbf4334562be59352a073ed40c09b3
MD5 ffd64aee108595695b97ff8ea939ef7f
BLAKE2b-256 108124ef6ded9dcc8a6a3134d69bc9b4c512bf437c5459ff1cea5e33bcfbbb8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.17.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 32467a45bff7160222cd1d7c1a7fc56c748222120eeeba5682af44bdbed20e85
MD5 54bf71c1d5e8d6a9c6a5c450ebff7888
BLAKE2b-256 456dbefadcd0b966b22283515012fccd49195469f6f066fe1c67a17349f7753c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_xdt-0.17.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 36b771ca705a0405c09be92deaeee93b4c657ba2940fa59312ae18fed53c39d4
MD5 be43e96b3c7e7db6c1ed926d3a3c4990
BLAKE2b-256 536312149bd0ce61b4d696f967fe219337668586767a51461a03f05d2b43e141

See more details on using hashes here.

Supported by

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