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.12.7.tar.gz
(976.1 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.12.7-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84ddbf07652cdcc2e3993dd02e42a7afe4bd48edecbf575def3844913bb76706 |
|
MD5 | 1b5d1c9adf601eb433cac2aae62fa492 |
|
BLAKE2b-256 | 1ea3963997515bafe991f46193cc47c9f0c8a73292ef7aa6b019643a6f89b6e6 |
Close
Hashes for polars_xdt-0.12.7-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a91258fd4e2a2d473536822cff2492e47f495fb9fb36f91ed2a44627324ca3ff |
|
MD5 | 427bb18f447393f27556761fae91f9d4 |
|
BLAKE2b-256 | ed1149712d51b23a6664be9b1c9eeb208e55729e7e9e24651e08b1d76f1b8d7a |
Close
Hashes for polars_xdt-0.12.7-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c596dbf647dd9f9e6a0b1108d68d429b3e2852eeed7b9ee9fefda89f7b64ead7 |
|
MD5 | a486eb1f3230835b71082eccd4846b60 |
|
BLAKE2b-256 | bf067b36f1ee192fcf11073838399574449c8c379c0267afbb0f86473cd4effd |
Close
Hashes for polars_xdt-0.12.7-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9002ce6dcc09ff2d95d6f8e77cb76c94488af0dfb7d047fa94eae80de5beb7a4 |
|
MD5 | cb1713bc5a014a2eeb2eff60a424864c |
|
BLAKE2b-256 | 477a79438f7775b009aeab062e9ccf75a4d19291ba39208bd6e033caed444ed3 |
Close
Hashes for polars_xdt-0.12.7-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63f838105c2397dfb2e4953414d6797e53b023d4595a9a7e0b159fd086590c2f |
|
MD5 | c875fb84b99aa4508bc90733770b426e |
|
BLAKE2b-256 | 574aa982130439668a2db210758bde89e49bbdf97efcf11d7a7c3f43676360c2 |
Close
Hashes for polars_xdt-0.12.7-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69e72fe3650db50a070b2339df442be0268d3bb76cc475ef43738a84b083b12b |
|
MD5 | 20c06355174120c9173946c2adc1f392 |
|
BLAKE2b-256 | 12b10e4bf41019540c979d9add55dd824b43e26cc7625a4175cbebb0e8c1ad29 |
Close
Hashes for polars_xdt-0.12.7-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e5757fc4edbda4db6146de2d02ce3bb7a3ae056fd2f2519dda5a8e15c6a3918 |
|
MD5 | e5807baf30282e2c655de6ce64f3724c |
|
BLAKE2b-256 | d2031813a0f635ef07fa5d768b28387583c053b13dd1fbcfae204198843a8f1c |
Close
Hashes for polars_xdt-0.12.7-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 209278670d34aca3c9342cdcd6e48e72ff7b7e5cd0c0ed8842356d0a7d80c153 |
|
MD5 | 47345b6c3aadb2e973ab280556a73471 |
|
BLAKE2b-256 | 1ee0e604129d993d97edeb0bbe25bdaa5662f23c1cabc3299717a3c94586224c |