eXtra stuff for Dates and Times in Polars
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file polars_xdt-0.16.7.tar.gz
.
File metadata
- Download URL: polars_xdt-0.16.7.tar.gz
- Upload date:
- Size: 986.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cbaeb1dd095bbfecb46ed693d7b2fc38adc400d6fb79f675e77397f30f89514 |
|
MD5 | bbf1a32f9f6451571d19a4482570dceb |
|
BLAKE2b-256 | 633bf0d466e4a4f0588ca1ad41e59099b0f49cae03d672acf5209a419ee851ee |
File details
Details for the file polars_xdt-0.16.7-cp39-abi3-win_amd64.whl
.
File metadata
- Download URL: polars_xdt-0.16.7-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 4.6 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bef5a85d197bff1341f75ec03a4d7a0933364445378fe7e3a1a5c282c4d5180 |
|
MD5 | c655ea440a4bca3ede72761b97de4eb3 |
|
BLAKE2b-256 | 0db4248e36a12885d2b70ef0d597cb3e75f0546da1e6cc2de05d73a3f5b4d3e2 |
File details
Details for the file polars_xdt-0.16.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: polars_xdt-0.16.7-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 5.6 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32bedc02a6ef8275731ba3df0087325291152843fc25be17f06c0766813f058a |
|
MD5 | 99c37183010d860eb5e945a64bf2ee9c |
|
BLAKE2b-256 | dbefba9279b7f58ad5dfbb15d3a1e366ed7d498ea82a47657ac97bb8852bda5b |
File details
Details for the file polars_xdt-0.16.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
.
File metadata
- Download URL: polars_xdt-0.16.7-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 5.2 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89a84cd195a0c57892df88f288fb94e40b86c059f33afc8f80d2b0edc34314b6 |
|
MD5 | 8557bc0ebc8eeb7fc0a83933f5d35395 |
|
BLAKE2b-256 | 18c4409760bc5b26ef6fe0f74468a2856d134b1d6758e2a858f538fc46f9de32 |
File details
Details for the file polars_xdt-0.16.7-cp39-abi3-macosx_11_0_arm64.whl
.
File metadata
- Download URL: polars_xdt-0.16.7-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.8 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aa5f54477b77a673b5b7fe7c72bc2ec6774f62d1ea4f95c9761cb174aaf686d |
|
MD5 | 0ed4b9c2ced098fb1293248806ea4b30 |
|
BLAKE2b-256 | 0caf1e622f5b81a42d8d0a230ab711875fa9958fc26e1f660c59c519c25ca525 |
File details
Details for the file polars_xdt-0.16.7-cp39-abi3-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: polars_xdt-0.16.7-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 4.2 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dde5fca2f04d4bcb70cc7abe677ab4d2fad80a7b308b831b8ec387d78cf2628 |
|
MD5 | cdfd8694144f06ab0ccfd59ff4166aa0 |
|
BLAKE2b-256 | 1c5ab53d465c21788ecbd4937cc390c9e0c7d771fb0e2780a7a996ee0a8de3bf |