polars-xdt
eXtra stuff for DateTimes
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.
Release files for polars-xdt 0.17.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| polars_xdt-0.17.1.tar.gz | 986.3 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| polars_xdt-0.17.1-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details |
| polars_xdt-0.17.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| polars_xdt-0.17.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.9 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| polars_xdt-0.17.1-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details |
| polars_xdt-0.17.1-cp39-abi3-macosx_10_12_x86_64.whl | CPython 3.9 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 31.3 MB
Release files / polars_xdt-0.17.1.tar.gz
| Download URL | polars_xdt-0.17.1.tar.gz |
|---|---|
| Size | 986.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a3860bf3c3015d519192102af4de687feabc6dbf6a038fc2f60cde72e9d0c45
|
|
BLAKE2b-256 checksum How to use checksums |
5dfc5aecdaf5d20a84e9e9daae4a41b9d8f06062467fedb4cdb609d32bcaeee3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.6
|
Release files / polars_xdt-0.17.1-cp39-abi3-win_amd64.whl
| Download URL | polars_xdt-0.17.1-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
a4c68e949e795df57b97ea787638920285553264745661e9506c19a0059811de
|
|
BLAKE2b-256 checksum How to use checksums |
d5f14f28e5d890dbebd83f1be960bb64a6dcb99e635d8c796bb04fa597a45711
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.6
|
Release files / polars_xdt-0.17.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | polars_xdt-0.17.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 6.8 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
8bae8fbf6a4e10fcddd62e0e28ad667b56ecd53d3b6228517a8c72ac384dd233
|
|
BLAKE2b-256 checksum How to use checksums |
14336e461ae16b55b580f75f4090cada72818f3c38e89a3ae28045660e16c207
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.6
|
Release files / polars_xdt-0.17.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | polars_xdt-0.17.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 6.2 MB |
| Tags | CPython 3.9 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
8aeadda0f9052588f226fc24df00e97fbadbf4334562be59352a073ed40c09b3
|
|
BLAKE2b-256 checksum How to use checksums |
108124ef6ded9dcc8a6a3134d69bc9b4c512bf437c5459ff1cea5e33bcfbbb8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.6
|
Release files / polars_xdt-0.17.1-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | polars_xdt-0.17.1-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.6 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
32467a45bff7160222cd1d7c1a7fc56c748222120eeeba5682af44bdbed20e85
|
|
BLAKE2b-256 checksum How to use checksums |
456dbefadcd0b966b22283515012fccd49195469f6f066fe1c67a17349f7753c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.6
|
Release files / polars_xdt-0.17.1-cp39-abi3-macosx_10_12_x86_64.whl
| Download URL | polars_xdt-0.17.1-cp39-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | CPython 3.9 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
36b771ca705a0405c09be92deaeee93b4c657ba2940fa59312ae18fed53c39d4
|
|
BLAKE2b-256 checksum How to use checksums |
536312149bd0ce61b4d696f967fe219337668586767a51461a03f05d2b43e141
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.9.6
|