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.7.tar.gz
(982.0 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.14.7-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 850f1db43e324b9907677c5a04f0395b15dd2610d96c2d5d20bfd8c1232ab823 |
|
MD5 | a7c8b992fce7a90be23558b6d13ff6f2 |
|
BLAKE2b-256 | 4443033689b8c7e616c63799207d75ce14c1838fefe64f19f70ae73e7967bbf5 |
Close
Hashes for polars_xdt-0.14.7-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6eaa3133dfd88e8925dee78a3dab3beb6c48187880f1b9b3bbe690e258b2525 |
|
MD5 | 20feb8edfb5a654a118013e3bb9fb75e |
|
BLAKE2b-256 | 88ffe64c3f92d5125e4bab6dc3719f371c17d3a6bc8c0e0c1cae43dd6649a850 |
Close
Hashes for polars_xdt-0.14.7-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b63aa564caabaa3894eb5696ccaf6c4e63dac273d55eb2933d97d31ab8068943 |
|
MD5 | f68a2e1f0dfcb2c9ac8ffd3aa48baa88 |
|
BLAKE2b-256 | 5890d74d37fdfdd801304482e5c32b054db874e6b15f003ca3029ad9534f81db |
Close
Hashes for polars_xdt-0.14.7-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42739dce48e34ae2df446a8a51061d20a5896b788cbd4b607ebb92bc3da27060 |
|
MD5 | 3cfc200fd12331a0fadd89fc0cccac01 |
|
BLAKE2b-256 | fd23984a24096b3baf07318e52c403efafe6aee9407a3745f91d3924740ad2c2 |
Close
Hashes for polars_xdt-0.14.7-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e94d6f4369a4eddadf58f0966887f6f64b37b6ea0c2f1acca39c4467dcccda6e |
|
MD5 | e2d8ff799630b961d4858999aac619f6 |
|
BLAKE2b-256 | 11c3668de53b060bfed29c8a61b01373254ced605925c35145e5150f8bd626ed |
Close
Hashes for polars_xdt-0.14.7-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65547a80bd526674427a80b77dd8b279c16c56e2ca7306fbd8179177abe51439 |
|
MD5 | 2b53c224eb6c11b0d2a7c09ea1f20865 |
|
BLAKE2b-256 | 8d3f4db4ebe434ce42933529f85624435873fd33eaa2219b0306e0fd9d169551 |
Close
Hashes for polars_xdt-0.14.7-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63dea77d9307add283b29d032fcf399b3a5b5c07f87a6c39a934cfae913b6894 |
|
MD5 | cfd42efc2dad2a57258c45d38bdbd315 |
|
BLAKE2b-256 | 5083c6238c8824f7a5efd62279341e5c6adff5786be97282474388ce8bb28e57 |
Close
Hashes for polars_xdt-0.14.7-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5192cab6e4ba2353938c3ee65d8eb4a3b3a730b88ec073891131010a57404312 |
|
MD5 | ea9ee296a3a79c36776a4c7bbc0ba3b8 |
|
BLAKE2b-256 | a3d304235a6a343cbf449b833b3bfb7c4551a65d7504f3640ac4eb3c2b7ee9dd |