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
- ✅ custom business-day arithmetic
- ✅ convert to and from multiple time zones
- ✅ format datetime in different locales
- ✅ convert to Julian Dates
- ✅ time-based EWMA
Installation
First, you need to install Polars.
Then, you'll need to install polars-xdt
:
pip install polars-xdt
Read the documentation for a little tutorial and API reference.
Basic Example
Say we start with
from datetime import date
import polars as pl
import polars_xdt as xdt
df = pl.DataFrame(
{"date": [date(2023, 4, 3), date(2023, 9, 1), date(2024, 1, 4)]}
)
Let's shift Date
forwards by 5 days, excluding Saturday and Sunday:
result = df.with_columns(
date_shifted=xdt.offset_by(
'date',
'5bd',
weekend=('Sat', 'Sun'),
)
)
print(result)
shape: (3, 2)
┌────────────┬──────────────┐
│ date ┆ date_shifted │
│ --- ┆ --- │
│ date ┆ date │
╞════════════╪══════════════╡
│ 2023-04-03 ┆ 2023-04-10 │
│ 2023-09-01 ┆ 2023-09-08 │
│ 2024-01-04 ┆ 2024-01-11 │
└────────────┴──────────────┘
Note that polars-xdt
also registers a xdt
namespace in the Expression
class, so you
could equivalently write the above using pl.col('date').xdt.offset_by('5bd')
(but note
that then type-checking would not recognise the xdt
attribute).
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.14.12.tar.gz
(982.1 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.14.12-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 842f738b6255de6d0de9755294125106de3e86fc10b2f284de1670168653e30e |
|
MD5 | 9368a53495c6803aeb01e8cf1d496125 |
|
BLAKE2b-256 | 3a244e190b3a4ff669b8b62f50c94264a41e3042d75dd08690bde74f3cb6489f |
Close
Hashes for polars_xdt-0.14.12-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b80e200fb36d82ecd6847168fc74af81fc6a083d1a13feca742c1bfe1dae506 |
|
MD5 | dc585e487c9507c6b4afef78d592a142 |
|
BLAKE2b-256 | fbaaa39e6134f1aabe34e24812584b786c7400271a225fb9d779772a50113ff5 |
Close
Hashes for polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb46301e41d2bf9935b0f3bb22fbf4fcae39130cadef6bc1378acc1b9c6a482c |
|
MD5 | 96944c3b04649d1f927707e40809ad87 |
|
BLAKE2b-256 | 1d32f8578cecb398953339007b2d0020870e0b733cb3e6d67dc2561141c4ef45 |
Close
Hashes for polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2dde137718466497fa66941884e60d4ef53a83b09c52f6d8de32dbd834c8162 |
|
MD5 | 3cbadc3ef5ee9149c5b53dbd01238d72 |
|
BLAKE2b-256 | cc0607337a11e098f176d4181e2a5d05c8d79847227f360f02a1d6cb33f108a5 |
Close
Hashes for polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7efe749688fbdc79f95deb214dad4a8bd926d5b6c98dede0697de09fe75b6a12 |
|
MD5 | bc01f3ca61031fb77ba4e2f1d61eb83a |
|
BLAKE2b-256 | 5ce27d5275b46266b5897de89a3ac5faa8fe2ed1b3a270e9dddb486bb0f0c6ef |
Close
Hashes for polars_xdt-0.14.12-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab351d6cbccad04e32c0899d8833eba1bd0880c00c5ef3b2f2a48bba6e88e13d |
|
MD5 | b2b83511a1095546e4f4076a8c193069 |
|
BLAKE2b-256 | 106c6287bae3e6b1aecc4ba4db80b58a865dfffed779e71c7ad9d2c2b1d1d120 |
Close
Hashes for polars_xdt-0.14.12-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6dff4ef1c09a8e8b6489d21d027e0794c616f2894264f6d3c342d58d0bb3666 |
|
MD5 | 56495046e28b606e311ed1ce4ca48986 |
|
BLAKE2b-256 | 5007c361ef2c6dc715578462e4465340ce7375263e75e1ca9f8c08c50442126b |
Close
Hashes for polars_xdt-0.14.12-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04a5dfc7ad92c385e0aa552556733d2e1931cdb8efc16239a4d576de08132333 |
|
MD5 | 3d5ff70ae5405908d28b45bc3c212541 |
|
BLAKE2b-256 | 830f4a3381ca9964184c333be13eb59588f5a384e5fa3313aeb9d67826de4d69 |