【发布时间】:2021-02-13 16:01:39
【问题描述】:
【问题讨论】:
标签: pandas-profiling
【问题讨论】:
标签: pandas-profiling
从文档开始有点难以追踪;具体来说
从report structure,然后挖掘到下面的函数get_correlation_items(summary),然后进入源代码并查看它的用法,我们得到这个调用,本质上是在摘要中loops over each of the correlation types,以获得摘要对象,我们可以找到接下来,如果我们查找调用者,我们会发现它是get_report_structure(summary),如果我们尝试找到如何获取summary arg,我们会发现它只是description_set 属性,如here 所示。
鉴于上述情况,我们现在可以使用 2.9.0 版本执行以下操作:
import numpy as np
import pandas as pd
from pandas_profiling import ProfileReport
df = pd.DataFrame(
np.random.rand(100, 5),
columns=["a", "b", "c", "d", "e"]
)
profile = ProfileReport(df, title="StackOverflow", explorative=True)
correlations = profile.description_set["correlations"]
print(correlations.keys())
dict_keys(['pearson', 'spearman', 'kendall', 'phi_k'])
要查看特定的相关性,请执行以下操作:
correlations["phi_k"]["e"]
a 0.000000
b 0.112446
c 0.289983
d 0.000000
e 1.000000
Name: e, dtype: float64
【讨论】: