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.14.1.tar.gz
(979.7 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.14.1-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b46ff12b4789a2aab4cbe8a2428e824c87f4f57004cbb112c2abb663b6b3275 |
|
MD5 | 372724ac763d281eea8f2f2fbcd6bd05 |
|
BLAKE2b-256 | 744f92788651c3f7c1f02edf257517fe80ddc69fd7d5ad3265168fe56bca0f02 |
Close
Hashes for polars_xdt-0.14.1-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08254034ea70d8da9c4f7c15b9383b02f324db63febe5107a3d56f7f4603ea83 |
|
MD5 | 2ab534ef48301c05eaef52a19b2b5c52 |
|
BLAKE2b-256 | c12bc8a7f1c19124c0cbf2eb386fbe940c1e3de75abad6598b7d0574d4a55b8b |
Close
Hashes for polars_xdt-0.14.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ed026a708ac2e4389c9bd9a2d65cc59398a1cb60bab79a00daddda5a05004ef |
|
MD5 | 51043e742746945131b01bd5b1995d67 |
|
BLAKE2b-256 | 7592f36b57d43e2773f503b6bc77d26211e27c4f486f88f7b008d9c8e6bf2d1d |
Close
Hashes for polars_xdt-0.14.1-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c16cd322848427c93170174a98792282ed74e4420c7fcc12fe5294fb645b12ab |
|
MD5 | 240e71604322bf29b97144c6b1523ca6 |
|
BLAKE2b-256 | 4dadd037f75d3533a77d51d00554ed425e2c4ca0f509b79c05bedc57689af26b |
Close
Hashes for polars_xdt-0.14.1-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea4ed2b2e081eee20957026b552ee33844043999ca8de7702bfad77af1b5d8e3 |
|
MD5 | fff9efe7abf22aa4a005c32b8522c185 |
|
BLAKE2b-256 | ce7a56129360f72895e5bd38eec14d4b8816e02b87f27aac2a4d8a1eb962018b |
Close
Hashes for polars_xdt-0.14.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95512bb29b57a99a2681596990fe5123960935f68cf115abca0ea9b26e17cc83 |
|
MD5 | e99077726f8a7a4ef499e7db480bcfca |
|
BLAKE2b-256 | 13c7044dd4d93d9b6b0b5ed6efb74719f583966f67cb26ffbc50d20f109b2481 |
Close
Hashes for polars_xdt-0.14.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62711cc908ea838bdbe49f1a8ddeb16cafab17e5529d148e90dea6397e6baa18 |
|
MD5 | 2142869a9e1bf926eb1dfcea83e7e3d2 |
|
BLAKE2b-256 | b4832733819b38454e1027ecff9d05a7e94e7d34f3c3a6696f469c61b542c6a0 |
Close
Hashes for polars_xdt-0.14.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0dfdcd25ba8a58ee4551f8cace898b7643e5173eb2d43a59547c676e2cf92c7 |
|
MD5 | 445e51de2d6a22583523e3383e2980ad |
|
BLAKE2b-256 | 286216a560076f3b7635433751a329c594ac14510deb5f93c493a722f1d6defb |