跳转到主要内容

Polars的商务日实用工具

项目描述

Polars-business

polars-business

PyPI version Read the docs!

Polars的商务日实用工具。

  • ✅ 极快,用Rust编写!
  • ✅ 无缝集成Polars!
  • ✅ 定义您自己的自定义假日和周末!

安装

首先,您需要 安装 Polars

然后,您需要安装 polars-business

pip install polars-business

然后,如果您可以运行

from datetime import date
import polars_business as plb

print(plb.date_range(date(2023, 1, 1), date(2023, 1, 10), eager=True))

这意味着安装已全部正确完成!

阅读 文档 了解小教程和API参考。

基本示例

假设我们开始于

from datetime import date

import polars as pl
import polars_business as plb


df = pl.DataFrame(
    {"date": [date(2023, 4, 3), date(2023, 9, 1), date(2024, 1, 4)]}
)

Date向前移动5天,不包括周六和周日

result = df.with_columns(
    date_shifted=plb.col("date").bdt.offset_by(
      '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   │
└────────────┴──────────────┘

您还可以计算两个给定日期之间的商务日数量,指定自定义日历假日,并创建排除工作日的日期范围。

阅读 文档 了解更多示例!

性能

单线程性能

  • 与NumPy相当(它本质上是一个Rust重实现)
  • 比pandas快一个数量级。

但请注意,Polars将为您处理并行化,并且此插件将与Polars的懒执行配合使用,无需任何数据转换。

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分发

此版本没有可用的源分发文件。请参阅有关生成分发存档的教程。

构建分发

polars_business-0.3.22-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.7 MB 查看哈希值)

上传时间 CPython 3.11 manylinux: glibc 2.17+ x86_64

polars_business-0.3.22-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl (7.2 MB 查看哈希值)

上传时间 CPython 3.11 manylinux: glibc 2.17+ s390x

polars_business-0.3.22-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (6.8 MB 查看哈希值)

上传时间 CPython 3.11 manylinux: glibc 2.17+ i686

polars_business-0.3.22-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (6.0 MB 查看哈希值)

上传时间 CPython 3.11 manylinux: glibc 2.17+ ARMv7l

polars_business-0.3.22-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.1 MB 查看哈希值)

上传时间 CPython 3.11 manylinux: glibc 2.17+ ARM64

polars_business-0.3.22-cp311-cp311-macosx_11_0_arm64.whl (3.0 MB 查看哈希值)

上传时间 CPython 3.11 macOS 11.0+ ARM64

polars_business-0.3.22-cp311-cp311-macosx_10_12_x86_64.whl (3.2 MB 查看哈希值)

上传时间 CPython 3.11 macOS 10.12+ x86_64

polars_business-0.3.22-cp310-none-win_amd64.whl (3.0 MB 查看哈希值)

上传时间 CPython 3.10 Windows x86_64

polars_business-0.3.22-cp310-none-win32.whl (2.6 MB 查看哈希值)

上传时间 CPython 3.10 Windows x86

polars_business-0.3.22-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.7 MB 查看哈希值)

上传时间: CPython 3.10 manylinux: glibc 2.17+ x86-64

polars_business-0.3.22-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl (7.2 MB 查看哈希值)

上传时间: CPython 3.10 manylinux: glibc 2.17+ s390x

polars_business-0.3.22-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (6.8 MB 查看哈希值)

上传时间: CPython 3.10 manylinux: glibc 2.17+ i686

polars_business-0.3.22-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (6.0 MB 查看哈希值)

上传时间: CPython 3.10 manylinux: glibc 2.17+ ARMv7l

polars_business-0.3.22-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.1 MB 查看哈希值)

上传时间: CPython 3.10 manylinux: glibc 2.17+ ARM64

polars_business-0.3.22-cp310-cp310-macosx_11_0_arm64.whl (3.0 MB 查看哈希值)

上传时间: CPython 3.10 macOS 11.0+ ARM64

polars_business-0.3.22-cp310-cp310-macosx_10_12_x86_64.whl (3.2 MB 查看哈希值)

上传时间: CPython 3.10 macOS 10.12+ x86-64

由以下支持