跳转到主要内容

更快的,更简单的,更健壮的Python数据分析

项目描述

py-utilz

Build Status Coverage Status Python Versions Platforms

方便的辅助函数,装饰器和数据分析工具,以最小依赖项简化生活

pip install py-utilz

dplyr 类数据语法

from utilz import pipe
import utilz.dfverbs as _

out = pipe(
    df,
    _.rename({"weight (male, lbs)": "male", "weight (female, lbs)": "female"}),
    _.pivot_longer(columns=["male", "female"], into=("sex", "weight")),
    _.split("weight", ("min", "max"), sep="-"),
    _.pivot_longer(columns=["min", "max"], into=("stat", "weight")),
    _.astype({"weight": float}),
    _.groupby("genus", "sex"),
    _.mutate(weight="weight.mean()"),
    _.pivot_wider(column="sex", using="weight"),
    _.mutate(dimorphism="male / female")
)
from utilz import map

# Combine function results into a list, array, or dataframe
map(myfunc, myiterable)

# Syntactic sugar for joblib.Parallel
map(myfunc, myiterable, n_jobs=4)
from utilz import log, maybe

# Print the shape of args and outputs before and after execute
@log
def myfunc(args):
    return out

# Only run myfunc if results.csv doesn't eist
@maybe
def myfunc(args, out_file=None):
    return out

myfunc(args, out_file='results.csv')

开发

  1. 安装 poetry: curl -sSL https://install.python-poetry.org | python
  2. 设置虚拟环境 poetry install --with dev
  3. 运行所有测试: poetry run pytest
  4. 实时渲染文档: poetry run mkdocs serve

额外的poetry/virtual environment命令

  • 在当前shell中激活环境: source activate .venv/bin/activate
  • 在子进程shell中激活环境: poetry shell
  • 添加/删除额外的包: poetry add/remove package_name
  • 构建本地包: poetry build
  • 部署到PyPI: poetry publish (需要认证)

项目详情


下载文件

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

源分布

py_utilz-0.4.1.tar.gz (44.9 kB 查看哈希值)

上传于

构建分发

py_utilz-0.4.1-py3-none-any.whl (54.5 kB 查看哈希值)

上传于 Python 3

由以下支持