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
- ✅ convert to and from multiple time zones
- ✅ format datetime in different locales
- ✅ convert to Julian Dates
- ✅
time-based EWMA(upstreamed to Polars itself) - ✅
custom business-day arithmetic(upstreamed to Polars itself)
Installation
First, you need to install Polars.
Then, you'll need to install polars-xdt
:
pip install polars-xdt
Read the documentation for a more examples and functionality.
Basic Example
Say we start with
from datetime import datetime
import polars as pl
import polars_xdt as xdt
df = pl.DataFrame(
{
"local_dt": [
datetime(2020, 10, 10, 1),
datetime(2020, 10, 10, 2),
datetime(2020, 10, 9, 20),
],
"timezone": [
"Europe/London",
"Africa/Kigali",
"America/New_York",
],
}
)
Let's localize each datetime to the given timezone and convert to UTC, all in one step:
result = df.with_columns(
xdt.from_local_datetime(
"local_dt", pl.col("timezone"), "UTC"
).alias("date")
)
print(result)
shape: (3, 3)
┌─────────────────────┬──────────────────┬─────────────────────────┐
│ local_dt ┆ timezone ┆ date │
│ --- ┆ --- ┆ --- │
│ datetime[μs] ┆ str ┆ datetime[μs, UTC] │
╞═════════════════════╪══════════════════╪═════════════════════════╡
│ 2020-10-10 01:00:00 ┆ Europe/London ┆ 2020-10-10 00:00:00 UTC │
│ 2020-10-10 02:00:00 ┆ Africa/Kigali ┆ 2020-10-10 00:00:00 UTC │
│ 2020-10-09 20:00:00 ┆ America/New_York ┆ 2020-10-10 00:00:00 UTC │
└─────────────────────┴──────────────────┴─────────────────────────┘
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.15.2.tar.gz
(976.2 kB
view hashes)
Built Distributions
Close
Hashes for polars_xdt-0.15.2-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a10f5223fb39c1a84a6c7106aad947d0d3d74695250cf6b970e56b8ea22ac2ba |
|
MD5 | 4c1a8169543cc2311942dd9a17103d30 |
|
BLAKE2b-256 | 36be295a1f9c99cb53ba9a0ed059cc7e76bd0fc2f1eb50bdd3fa4210a3d9ef92 |
Close
Hashes for polars_xdt-0.15.2-cp38-abi3-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd34173c013a5c2db36e226e69cc977efc76d41d16f2fe5e9004b79890274ee8 |
|
MD5 | acc1ac8fc193c4b37f3810b9572743bf |
|
BLAKE2b-256 | bf6cbba7dc4332c9abe1411d6c927187eada93871cd08721367755af92240935 |
Close
Hashes for polars_xdt-0.15.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57358191b5e7fabbab7ce605f74483c5712511f5d6d1d4972aa798a5627a6dc7 |
|
MD5 | 91a2e782a5945bad99c14bc7c721d8e3 |
|
BLAKE2b-256 | a59661af44d434dea68270237cdd497aac21332e82a3cdd4cc24635ae89ad07b |
Close
Hashes for polars_xdt-0.15.2-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3fd4b63905b032082250da1abf5be0e85146cc6b87f4be25b9b918cc5dd135a |
|
MD5 | cd18ec1262af9e9f64814847ae458d89 |
|
BLAKE2b-256 | a3a2a8966ea7c46e88e92404e7090be171ce50c957a937e27b7cad2b64a2db20 |
Close
Hashes for polars_xdt-0.15.2-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66414a21e2591bbf2c56df750c9b7c7cd96a6cdd74fe9f1412bf9a1917f29a40 |
|
MD5 | 18c2669f88c4ce42803b6acc46c73d02 |
|
BLAKE2b-256 | 18801d15a3780622c7111ab5f1e32106c70ebf30dcc71cd34e444db59a14c548 |
Close
Hashes for polars_xdt-0.15.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6be413eaf24403af2216b3321bdea5cb1e6c4ae7a5bf96f98003ae560e1617e |
|
MD5 | 78eea5ef13b4328dca0f74e143445edd |
|
BLAKE2b-256 | 1f100de61e4797412dd6d5f14767f87a48925aa155b648ce1cf5f022acc25309 |
Close
Hashes for polars_xdt-0.15.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b868770fa91fd3fdb572501a8f46814f4e9a3d8004a009e181a222de7909702c |
|
MD5 | 662b8d406d4d422a1f089daa83bbad9d |
|
BLAKE2b-256 | 57ec068f0b99db1b91212386f1bcbe16efac0bb54d35a43a0423a376c923ab69 |
Close
Hashes for polars_xdt-0.15.2-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d494ba47ce2e69e1db7651c6275c93bd63a66bbc4516231a57da2dafb0b35b08 |
|
MD5 | 1eebb3608b1d35898eff781f2778b363 |
|
BLAKE2b-256 | 1ecb150c6882afba30ebd137309560f69a0398efad13999f1f9e9f27d3311a6b |