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.3.tar.gz
(979.7 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.14.3-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f39f59acf043bb2c2cdbcc7041fc75be3e22886295c0a6fb7d234ee226826f6 |
|
MD5 | 2a736fa4002b2f53f8ffb39b20083bc9 |
|
BLAKE2b-256 | 62417f46829cc77bf6c906a87dfbff343736577c9574f602a4cdaaf08ec84e39 |
Close
Hashes for polars_xdt-0.14.3-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d71b8f0f5448590cc5c6d7a6aece56686774d41028c447e2b7d6c5a90ed474e |
|
MD5 | c9dac435a10a05d361570a58b78291b2 |
|
BLAKE2b-256 | 1411ba3901559d2441bef7a50703c46da5dc1a0eba26c16fa7ea020f83783516 |
Close
Hashes for polars_xdt-0.14.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba8e98a6d813b625e4b384d73e9de4c82750775bfdfcf63f6cefb8bac6aa81b0 |
|
MD5 | 0bbf9926bce22783bfe34e00f7455d0a |
|
BLAKE2b-256 | 2b09b13951160c41187d490d3b308d22029b89576c6c0e25090f8cd7e527ad34 |
Close
Hashes for polars_xdt-0.14.3-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f25ac02a65a05d1f2b1eae816548c1917700e4db4be32befff0f61e5858f3b7e |
|
MD5 | aa23aab8a701324d508b1f7d1e230d3c |
|
BLAKE2b-256 | 390262fcfafcdb0fc7f4a35f4d7d70f64286ffdcb3459dc982f9bf45f811613e |
Close
Hashes for polars_xdt-0.14.3-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b583e6a02dd9681dc2fec3c76deb20f525b55c14479bfcc0ef85cc0b15a7fc05 |
|
MD5 | 4b0f4af728737fea50929709d62ce0f9 |
|
BLAKE2b-256 | 47867cb90cc0a44fe372c65aa9566a4aa84972348bed93b8efc36c4db7bfa8b3 |
Close
Hashes for polars_xdt-0.14.3-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d710e7bb09aaf595d66ff6a598c673074ce4ee03be5f624f9dc2e3fae3983b24 |
|
MD5 | 6aebc129083ef70ebebf09ff1786c6b1 |
|
BLAKE2b-256 | da8d81fcd9446f8730fec4c343f1dc32b9a775e25a084fd157e68e2f21f1e26e |
Close
Hashes for polars_xdt-0.14.3-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c51fdf55176edb277baea6c697176fb153ffd6ce0009cde398d795693915549 |
|
MD5 | 426c09945a70409e7166c859e0370f2f |
|
BLAKE2b-256 | 0667b3d08d284105c4fff588b95a9e420687c695cb197a4e0bf4161fa437ca9c |
Close
Hashes for polars_xdt-0.14.3-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9742b4e123f0feee8b5614f95c5c70fe4ccff6026f572f212ac2ff316ee4f26 |
|
MD5 | 66f1958d5f5a6aadbca2c82298cb59a2 |
|
BLAKE2b-256 | cbd87f5412d8b7b92dce6f6189db8b5fa7d38696aaa8f48400b60500bed59b7a |