Skip to main content

Add your description here

Project description

pdcleaner

Description

用于清洗pandas数据表格

安装

# 安装
pip install pdcleaner

# 升级
pip install --upgrade pdcleaner

# 卸载
pip uninstall pdcleaner

使用示例

import pandas as pd
from pdcleaner import DataSet

def test_clean_data():
    # 生成测试数据
    test_data = {
        'Column 1': [' 1,234 ', '-1,253.8', "增长369,666.0", "1,2,3", None, '-'],
        'Column 2': ['20%', '98.88%', "1,235.69%", "增长10%", '-10%', '50%'],
        'Column 3': ['  extra space  ', 'no change', "'single'", "multi\nline\rtext", '1,234.56', '25%'],
        '数据写入时间2': ['2023-10-01 12:34:56', '2023-10-02 13:45:56', '2023-10-03 14:56:57', '2023-10-04 15:07:58', '2023-10-05 16:18:59', '2023-10-06 17:29:60']
    }
    df = pd.DataFrame(test_data)

    # 调用 clean_data 函数
    cleaned_df = DataSet.clean_data(df, drop_cols=['数据写入时间2'], rename_cols={'Column 1': 'New Column 1'}, add_time=True)
    print(cleaned_df)

if __name__ == '__main__':
    test_clean_data()

参数说明

参数:
df (pd.DataFrame): 输入的数据框。
drop_cols (list, optional): 需要删除的列名列表。默认为 None。
rename_cols (dict, optional): 需要重命名的列名字典,键为旧列名,值为新列名。默认为 None。
add_time (bool, optional): 是否添加数据写入时间列。默认为 False。

返回:
pd.DataFrame: 清洗后的数据框。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdcleaner-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdcleaner-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pdcleaner-0.1.0.tar.gz.

File metadata

  • Download URL: pdcleaner-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for pdcleaner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cba5cf90f3f349caf8623bb8a4ed7b29634fe20943a3d1e6ef76f825098fd07b
MD5 b2f1c2c8ae484b519950050babfb1bf2
BLAKE2b-256 c61de0b3969dbdfbdb38809f7d409b4d1474cf4edc938424e8a8a472276b6de4

See more details on using hashes here.

File details

Details for the file pdcleaner-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pdcleaner-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for pdcleaner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9667ad2f2e7c2918ff0c86e75949571f757399b83eeebaa7f241fb97b36c1a6
MD5 161194bd8a5c4c321771848f60b6619d
BLAKE2b-256 3881dfc8af0e06113e7c7a35a74d364157a85ab70eeacf05848e5aa0dd4fac4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page