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
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.12.11.tar.gz
(976.1 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.12.11-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b11c8dadad90836117778d2bcb9676f00bd9c9a9f79f4c8d39d2b08baf3f186f |
|
MD5 | df27f93ac89181919eac3f7bcb7da74e |
|
BLAKE2b-256 | 8b1ea738cbd667c21240487f011b28b9a3247e8112292ab87190e568124fa892 |
Close
Hashes for polars_xdt-0.12.11-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 286ded8c2418d90eb9849105df428793b9315cb39ecd272ed0ad634190a499fa |
|
MD5 | 8778c23ab16c007dd1f6f432e48587b9 |
|
BLAKE2b-256 | 452a36de9cda00ee01a33070478bd728262ab94900bf32106063145068e4e5a2 |
Close
Hashes for polars_xdt-0.12.11-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19a621fa411b3ab8125b4d55b4c41010858a42984bc9dd97723a327fe14dccd8 |
|
MD5 | 4ee74b3262e6d048d9f498633a2e7617 |
|
BLAKE2b-256 | 5f82ea0d3bd0f6ec35438b695d3206b8cc43c0595d1ca8c6fde7d25b83cc7c17 |
Close
Hashes for polars_xdt-0.12.11-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7079a9006f6a37585f79550c508f3c91c6534c3847e31433390b5f7df9372541 |
|
MD5 | 64def0e974d457eb65a1a048f06b2e55 |
|
BLAKE2b-256 | 122d40bcc54ff802580943c011538a8e6d9a2c75742138a2ff61ba0093f3855e |
Close
Hashes for polars_xdt-0.12.11-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f68969e3d61a0f26146ba02af53af8eec992dc4775aeb86d8de48b2ba92eebf |
|
MD5 | 53ebcc3c92adaddb6bfc94c5b8fe0f18 |
|
BLAKE2b-256 | ef4bc72de66cd4006a3f245829bff5ea2a8113d73ea9e10b21ca77dc70b6f706 |
Close
Hashes for polars_xdt-0.12.11-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 323204414bca72685c667ae9bc7be07c4bd9dcaa777cd57e289e411cea84644a |
|
MD5 | be06ac620e72122ec3f1fd89e478b294 |
|
BLAKE2b-256 | 1a6beb4f7350796cf55fef6849d84b8b3c6dd7caeed70959028f61216cb91a83 |
Close
Hashes for polars_xdt-0.12.11-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b60bf8eccfb4ce8e2dda3ebb5b957ed51f7091949036162028979534bbc07991 |
|
MD5 | 51ef678ea5dc1d089b4884d641f44cb1 |
|
BLAKE2b-256 | 0b732ddea06f351740b7f37d3717466904e165ce1535cc07fbcbf773a64f0eea |
Close
Hashes for polars_xdt-0.12.11-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b37bbc11396d311bf400466025b4b4f29ba71cbefac8f31fe2698a0b3e7f9817 |
|
MD5 | e2dbc0cd8e4c09df127a1a49d0126d9e |
|
BLAKE2b-256 | 8aa45b7576596e806b9bbb29e140d3a5a1e5348dd238646115f4565b9773b297 |