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.10.tar.gz
(982.0 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.14.10-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01949b6e40711b8c488c8786cf3b515f06d3b648d0fe7b6a8281df52a1e94208 |
|
MD5 | 47048c2695a3878deba5f3c7d14f0f98 |
|
BLAKE2b-256 | ddb87745297b67beb0751ebebc88e878be89a509858344055bf913896b67ecf4 |
Close
Hashes for polars_xdt-0.14.10-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 200a1c9280a2e660ff57146cdbe2858d41ee610ce7e6805614684011df912b49 |
|
MD5 | 0a9c2f0cbb2ea07d900dafde7c5ba137 |
|
BLAKE2b-256 | f14f179f2af3512dd8d03e15bc9fc1ecc00f4c8fad030bc3dffb92136bf9868c |
Close
Hashes for polars_xdt-0.14.10-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5112b78033f9a55d77dabcd43c9deef0abafa6f52d5dae052c0421555c5a3f15 |
|
MD5 | f5f653b4e4cfe034d8185cff2e1a9a6b |
|
BLAKE2b-256 | 78cdf52d3b75cac21efcbd25883d85be9bfd068e2e8ac6824671c5ee1aaf3d5b |
Close
Hashes for polars_xdt-0.14.10-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 430c90797eb963e4b05d8ecf6676f2108ee8f09a013ba4f17c8ff1e2eb79022e |
|
MD5 | 1dbfeee634521d9df9c1b53748626da2 |
|
BLAKE2b-256 | d8c3d6425125b7863844d6011af18666359071aa529ac64d4a806d214f1a1bf5 |
Close
Hashes for polars_xdt-0.14.10-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce0db923226796816a56217c6d6a9a47569a0b4e5527ddab601db60fe4a1b6fa |
|
MD5 | b4caedf5cf6febb78caae2503f708f73 |
|
BLAKE2b-256 | b1ca789f818a1f863e31518db307c745b32e0d20913853480a3f307c66601412 |
Close
Hashes for polars_xdt-0.14.10-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64ab477f6ba7bdab0d79ec811f7261e50b90af7bbbbee902da3af0eca2e167e4 |
|
MD5 | 6a56a68854aa5e17c2971852868c8f89 |
|
BLAKE2b-256 | ce0f57730508f2f370e86e322e37e7d57ec65765e53cfbee9fdc098d7d74d73b |
Close
Hashes for polars_xdt-0.14.10-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cec536981ce440fdb879f3eff1f053791460840de3ca23d1a0dc83429f5dcad |
|
MD5 | b477e3448b58699af01626ea122f081e |
|
BLAKE2b-256 | b9c69b4c15edf9d67e322ca20034359fe175036e164d5153f81474ce55fbe709 |
Close
Hashes for polars_xdt-0.14.10-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10f66d9de375c2c12d39e391e2eba6c616d05e84da0af39930421bab74a024dd |
|
MD5 | 2c3166540b99120106bd1a10f06ac441 |
|
BLAKE2b-256 | db0b02af0ba3e12f1616858ccbbd043bb77bd3a07239f83c7d482dea0a40ad69 |