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.8.tar.gz
(976.1 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.12.8-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fab3f37090e0b035c05268194c57221bffbce894225db01ba479a42ef256e57b |
|
MD5 | fd486ff5413905ddce438a44c713fd73 |
|
BLAKE2b-256 | f02f24b4efda9d73c456fd39154b68b6abfaa4cb51ecb45b9bda8f95c68fdbbe |
Close
Hashes for polars_xdt-0.12.8-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 184ab1a1b5c3d156beb23c6187dd42995c686b2b89fc1f5c506feffc5f68dddc |
|
MD5 | 8611bf893e5b4d6c5189e638ebbce3bb |
|
BLAKE2b-256 | 2f27375e2f97835acd91f8671257a6aabd842fd435a0a804ccc909d61bb1dbaf |
Close
Hashes for polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c05d5ef560c8fd8e796bc24c95ed5aacc92a358c89c404f25a29459fde8f9428 |
|
MD5 | a1336b14ed332c7134a76ab01c49316b |
|
BLAKE2b-256 | bb33701627c11b16d9a2dcf918a4f477ef969733716acc25b09040491c1dd5a1 |
Close
Hashes for polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09d0b6ac8c5dd771351e563b074f2443913799d35225c3f4cfa155dae49b70ea |
|
MD5 | 2ac95380f6032f31c77fca9eecff05ff |
|
BLAKE2b-256 | 7d0c86233682d5c428d4a5af2c1b248a3ffa6d1705b0031dba10f3d7decd479a |
Close
Hashes for polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9963e09cd7254c438e049d1eae36a0c13510f6b9ea8ec77d831e47af6b200aae |
|
MD5 | a02bd4322c37ab91461f7f5c91e030ea |
|
BLAKE2b-256 | 15e76f857cff6936f5a312fa840b62e96d81bcb02348d51f554f34b13e430fdb |
Close
Hashes for polars_xdt-0.12.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9c06f48f0ff930fb906f336d332994d8519cd4a09bd42b0dfe73e5ed19e2e4f |
|
MD5 | 4ef3057494c3c452192bd3682b126140 |
|
BLAKE2b-256 | 82f326b9ad005fad60d0c00feee2205d5bcc0af08025126d66729edb2ce4c4c5 |
Close
Hashes for polars_xdt-0.12.8-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34be6224e706bad5de4690fd88ec5a727a1bcd789d22d2dd5167f83e73cf48cf |
|
MD5 | 69beebd7b3a4952175d19290bb5d1ccb |
|
BLAKE2b-256 | df3cc9d375ed901d1e4ae197d1e3c3ededd5031906e3b6f2475209843b65864b |
Close
Hashes for polars_xdt-0.12.8-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c2a697f7e0dc53b987d3bf1f8d2b83b4bf9c4bc4d454d92928a92183dda9c09 |
|
MD5 | 270eb6b993b669b910c62f16aff2cfaa |
|
BLAKE2b-256 | 2df7a2cdc8ef95b498d1c008e3c6a6b0fb0f9be9f2f1804b053aaf8aba7fbf2a |