【问题标题】:when i execute pandas-profiling package it won't return min, max and mean values当我执行 pandas-profiling 包时,它不会返回最小值、最大值和平均值
【发布时间】:2020-08-26 14:49:30
【问题描述】:

当我使用 pandas-profiling==2.8.0 分析以下数据时,它不会返回最小值、最大值和平均值。

CSV 数据

a,b,c
12,2.5,0
12,4.7,5
33,5,4
44,44.21,67

python 代码

import json
import pandas as pd
from pandas_profiling import ProfileReport

def profile_report(data):
    dataset = data.select_dtypes(include=['int64', 'float64'])  
    profile=ProfileReport(dataset, minimal=True)
    json_data=profile.to_json()
    results = json.loads(json_data)
    print(json.dumps(results, indent=4))

if __name__ == "__main__":
    df = pd.read_csv('data.csv',index_col=None)
    profile_report(df)

在某些情况下,它可以正常工作并返回最小值、最大值和平均值。但是当我执行上面的 csv 数据时,它不会返回该值

【问题讨论】:

    标签: python-3.x pandas python-3.6 pandas-profiling data-profiling


    【解决方案1】:

    对于元素少于给定数字(例如 5)的数据集,pandas-profiling 假定您的变量是分类变量而不是区间。

    使用vars.num.low_categorical_threshold 参数更改此设置 (docs)

    例子:

    profile = ProfileReport(dataset, minimal=True, vars=dict(num={"low_categorical_threshold": 0}))
    

    【讨论】:

      猜你喜欢
      • 2018-07-16
      • 2016-12-29
      • 1970-01-01
      • 1970-01-01
      • 2015-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多