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
polars_xdt-0.15.3.tar.gz
(976.4 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.15.3-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94711e34fef6604d57e2aedd3b90f87e9fa53dab9d2e749667e01a3967b87e1e |
|
MD5 | 2f51ad6bcd510e6118c3aa5f055da46d |
|
BLAKE2b-256 | f9c34d78c5c73efcdb618e88a2436db24807abdf9b1fedafcb7469e7e79b3978 |
Close
Hashes for polars_xdt-0.15.3-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b6c77fe0e9360c9b656d435dc9147b1bd9d29b57a0af47dacf76886b0490d6e |
|
MD5 | d31f98c2e46e07add1c3af296bcb5507 |
|
BLAKE2b-256 | cccdcf2d7736063e25ec311c017b1fe3df3c7d00b010ee51378f03cf54f3bacd |
Close
Hashes for polars_xdt-0.15.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60fb3fe6dc3121573b5fd63d21965f851b0e021dda896a985f896b74f738f39e |
|
MD5 | b7b160cde94e8c3c0aac696f4779edb8 |
|
BLAKE2b-256 | 89473044273ecb37cba0ee17c8a13211e23ae7142d37d04b5844a78fdaf143c2 |
Close
Hashes for polars_xdt-0.15.3-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af417b211c7cae155d4187c4709d7100039f6cc819cb73259b23eae405a64fed |
|
MD5 | dcd66f349564f718c46981972168134a |
|
BLAKE2b-256 | 31810277d723aa75018cc2c4ab44ecea36cd9b5d650940f72966e63584327eea |
Close
Hashes for polars_xdt-0.15.3-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59b614eb32c6da308f78f6d81b737e15699710fe269f616055c764afd037ea4e |
|
MD5 | bd1337428628b45fdb1e65f30b3c3a5a |
|
BLAKE2b-256 | f6af6736b1714cab6ec8ecd137c61188a094d03d468dbbd708301962cce4764e |
Close
Hashes for polars_xdt-0.15.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81687d36ba0b914b0bf019a9618f3c2dbcc15218e2d278508c4e6b161e64f57a |
|
MD5 | d2551148f76e2ec222aa66e56a527b05 |
|
BLAKE2b-256 | 257d2bd336e1657973e3e5e15720ad55598cc2f81fe85e95f8f471003bdfa592 |
Close
Hashes for polars_xdt-0.15.3-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af69531804f5a0985924ab4a41b835d866dc3c1719660c90e875d2c38de50a99 |
|
MD5 | d54230d8f74424f129cd7f4828f0f567 |
|
BLAKE2b-256 | 860d6e59347c63a57a60d6a35fe758fc269afc45cd21e46edb610da614669078 |
Close
Hashes for polars_xdt-0.15.3-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34b28d389934be85aa5238255a4ef031552d5f712d79d9368353f6e4e2c00e07 |
|
MD5 | 86cd7174bcab2f7de086f3a73c22f8d8 |
|
BLAKE2b-256 | ef9f14e9389db5d2204100cd5ad6ac9f754da3161cb85bfdca3e007d34642fd6 |