跳转到主要内容

OS-Climate Python工具,用于帮助标准化数据摄入工作流程

项目描述

osc-ingest-tools

python tools to assist with standardized data ingestion workflows

安装、使用和发布管理

从PyPi安装

pip install osc-ingest-tools

示例

>>> from osc_ingest_trino import *

>>> import pandas as pd

>>> data = [['tom', 10], ['nick', 15], ['juli', 14]]

>>> df = pd.DataFrame(data, columns = ['First Name', 'Age In Years']).convert_dtypes()

>>> df
  First Name  Age In Years
0        tom            10
1       nick            15
2       juli            14

>>> enforce_sql_column_names(df)
  first_name  age_in_years
0        tom            10
1       nick            15
2       juli            14

>>> enforce_sql_column_names(df, inplace=True)

>>> df
  first_name  age_in_years
0        tom            10
1       nick            15
2       juli            14

>>> df.info(verbose=True)
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3 entries, 0 to 2
Data columns (total 2 columns):
 #   Column        Non-Null Count  Dtype
---  ------        --------------  -----
 0   first_name    3 non-null      string
 1   age_in_years  3 non-null      Int64
dtypes: Int64(1), string(1)
memory usage: 179.0 bytes

>>> p = create_table_schema_pairs(df)

>>> print(p)
    first_name varchar,
    age_in_years bigint

>>>

create_table_schema_pairs 添加自定义类型映射

>>> df = pd.DataFrame(data, columns = ['First Name', 'Age In Years'])

>>> enforce_sql_column_names(df, inplace=True)

>>> df.info(verbose=True)
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 3 entries, 0 to 2
Data columns (total 2 columns):
 #   Column        Non-Null Count  Dtype
---  ------        --------------  -----
 0   first_name    3 non-null      object
 1   age_in_years  3 non-null      int64
dtypes: int64(1), object(1)
memory usage: 176.0+ bytes

>>> p = create_table_schema_pairs(df, typemap={'object':'varchar'})

>>> print(p)
    first_name varchar,
    age_in_years bigint

>>>

开发

可以通过向 https://github.com/os-climate/osc-ingest-tools 发起pull请求来贡献补丁。

所有更改必须通过自动测试套件,以及各种静态检查。

强制实施 Black 代码风格和 isort 导入排序。

建议通过 pre-commit 启用自动格式化。

pip install black isort pre-commit
pre-commit install

为确保符合静态检查工具的要求,开发者可能需要运行;

pip install black isort
# auto-sort imports
isort .
# auto-format code
black .

然后可以使用 tox 测试代码。

# run static checks and tests
tox
# run only tests
tox -e py3
# run only static checks
tox -e static
# run tests and produce a code coverage report
tox -e cov

发布

要发布此库的新版本,授权开发者应;

  • 准备一个带有对 setup.py 中 version 的更新并签名的发布提交;
  • 使用带“v”前缀的语义版本控制标记提交;
  • 推送标签

例如;

git commit -sm "Release v0.3.4"
git tag v0.3.4
git push --follow-tags

GitHub 工作流将自动将版本发布到 PyPI。

项目详情


下载文件

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

源代码分发

osc_ingest_tools-0.5.3.tar.gz (16.5 kB 查看散列)

上传时间

构建分发

osc_ingest_tools-0.5.3-py3-none-any.whl (16.6 kB 查看散列)

上传时间 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面