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.13.0.tar.gz
(977.3 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.13.0-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17c2f68e526c4fcb51df157a38854256f3fc954824804bf6bacc3be924084866 |
|
MD5 | d36fa8f335f1ecc00867dc118a880c00 |
|
BLAKE2b-256 | 772a18e26033bef7c3a22188c20326711d82e10855e3c3757eee3f45e690d494 |
Close
Hashes for polars_xdt-0.13.0-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65094b6529331cea251a171afa15663ea366066df925aec4b663a521c548b4e8 |
|
MD5 | 3b35ac5b4ba6958e3cbd3b5fac6cf9c2 |
|
BLAKE2b-256 | 653cb14cdd0337a790309eb1c58bc3aa58abbbf9bf25a1d0ebef50829e05037c |
Close
Hashes for polars_xdt-0.13.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57fb5c7c8b5598bef360f11116b3af41ec6667f4d5d8a497e0c8a18cb7f5995e |
|
MD5 | ff37299bf869425a39933729d13c2b91 |
|
BLAKE2b-256 | 4ad2a47e8ec728c92efe1d68d810d5258e5c8416c0edea4fa1109d8fbd023a71 |
Close
Hashes for polars_xdt-0.13.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eeefa58b577b6275400524d2a20f2d40392d834e0e78143f1cc2b4b5bfc07282 |
|
MD5 | aceab8196abe20fc09cd3f6f874df07a |
|
BLAKE2b-256 | 05a1f1c09fc013921e001a14f3b35f1f67c5c6ac0594787fd266713531054531 |
Close
Hashes for polars_xdt-0.13.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d873a66d8806d38e02376c35c65420e88c5b90d245a85a496f351cc95d688f5f |
|
MD5 | 17cad094cd2fbd729ff2ba697cfa6cb6 |
|
BLAKE2b-256 | 26ddbaf26c7bf3299d970a970a86c0e417409fc11f6405635c92f4c0c5a3ed5a |
Close
Hashes for polars_xdt-0.13.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5c59a6c5ebc9b34a11aca495a23dfa19e92131e8eb13ec5a721ef3812ddc3f5 |
|
MD5 | fa2cf041c88ce18adb4f9cd55c23d620 |
|
BLAKE2b-256 | 73e3d3253a0e1443c3696b7d956ce465ba998e9a0cb42972a704e3b0a92217cd |
Close
Hashes for polars_xdt-0.13.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08282cbca6ec3dc9f9bafd9182731a5047bc684d267170973c252daa78bcfebf |
|
MD5 | deec90d16ebc320b8ab921870e9a949a |
|
BLAKE2b-256 | 87388cd8f067c01d0fafdf1489e6145c523bf3d6a66b4d3d955721d2541ea58a |
Close
Hashes for polars_xdt-0.13.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 321da1c5a48695401253699dd791c449be037f6c2bceb11a5d32a64394a51256 |
|
MD5 | 7ea7840052ab9e9fd82dcb5288b8c4c3 |
|
BLAKE2b-256 | 5bd5b27c2c0cd24204b5bd06c928b8402d66feabeccce90c69eae5ee800187e5 |