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.2.tar.gz
(979.7 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.14.2-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2487b41534d757573477945f1ebfd8c453b98bb8a251607817126e4da8866fb5 |
|
MD5 | fb81c6557a261d2c336f8609ed94bcd1 |
|
BLAKE2b-256 | 7d6d869bfe6821e90d43fb7359b44e979c80f43a62e1dfbf1a7fe4d7d5e9488c |
Close
Hashes for polars_xdt-0.14.2-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba3b004cfa36c3907042f24793017e657b541a6709a74dc7154b4bbd04f0c613 |
|
MD5 | b194d047230d9c8962bb53b694e389e8 |
|
BLAKE2b-256 | 3e4bbee0c0d7af085c40e930bea8fb718dd3567b9188598b4d9d9f6db61cd434 |
Close
Hashes for polars_xdt-0.14.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea8f247b9c74ba33c278bc7948d49ca06797de09eb58466b44cb1e6701c020c5 |
|
MD5 | 8e857ff574d642bd23fcb7d0bd69dce6 |
|
BLAKE2b-256 | 44bfc662a6fddf10070f8a26c1c01cb9ed7113311a8315064beda3ea24833e66 |
Close
Hashes for polars_xdt-0.14.2-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65fcf3205501527543fa5161bced38171b262ea1e3a19641ba0cfad02012dce4 |
|
MD5 | 67d8ed9e84a6502f1095575f11bb4070 |
|
BLAKE2b-256 | 6d8e2adb108aaa109db5bf327a0e3f638a62024565b8de388e28ea1fe2ace13d |
Close
Hashes for polars_xdt-0.14.2-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a364ba802db099269028bce6592751c73cdb0e05bca10ffcd23670630b84112 |
|
MD5 | 03c09bc5b794a60812a1c50fdcfb2b57 |
|
BLAKE2b-256 | b35a09e660c0d27caee1ec852b28e8b47b5f96ad550c748d0e738b4cedb9b4eb |
Close
Hashes for polars_xdt-0.14.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57120e9c46bdc775cd5896e2897c04cf1f71c0ab04777bd4fbc710be0be6d100 |
|
MD5 | fc7f98773e7d83bd045be3a76135942e |
|
BLAKE2b-256 | 0de380cf4cfd9910971c91a0e9a48357274a307517a6554bcf69b825c387e4fc |
Close
Hashes for polars_xdt-0.14.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f866fe2d2672888fa44272db47837739f2a51052ea4b47d1d66a7db0d4b856de |
|
MD5 | f9998d57d490fffbe6bc92023e574525 |
|
BLAKE2b-256 | 69650d2278bd5286033311f2339c78d429db67d33fb2f1494f28c91cdb0e3311 |
Close
Hashes for polars_xdt-0.14.2-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd16f53c32d942d53b88d128f15dd7267aa1ee5b96df4561cc70bc9501ed270d |
|
MD5 | 6d3ff4138f0d0cc6d661cfc07dd18bfc |
|
BLAKE2b-256 | 6ec11fbb825f2cc893e34d9e4b646a848675ff03f5ff5faae4679036c7824a0e |