4

我想使用 pandas-profiling 对数据集执行一些 eda,但出现错误:AttributeError: 'DataFrame' object has no attribute 'profile_report'

我在 spyder 上创建了一个 python 脚本,代码如下:

import pandas as pd import pandas_profiling data_abc = pd.read_csv('abc.csv') profile = data_abc.profile_report(title='Pandas Profiling Report') profile.to_file(output_file="abc_pandas_profiling.html")

AttributeError:“DataFrame”对象没有属性“profile_report”

4

8 回答 8

5

入口df.profile_report()点从 v2.0.0 开始可用。从这里解决

您是否通过 pip 或 conda 安装了 pandas-profiling?

使用: pip install -U pandas-profiling 解决这个问题并重新启动你的内核

于 2019-11-26T06:15:38.370 回答
3

问题是团队尚未更新 pip 或 conda 安装(在此处描述)。如果您使用其中之一安装,请暂时尝试此操作。

profile = pandas_profiling.ProfileReport(df)
print(profile)
于 2019-08-28T15:13:23.033 回答
2

对于那些使用 google colabs 的人来说,分析库已经过时了,因此使用下面的命令并重新启动运行时

! pip install https://github.com/pandas-profiling/pandas-profiling/archive/master.zip 
于 2020-10-16T14:35:02.657 回答
1

这应该适用于那些想要使用最新版本的人:

  1. 从 anaconda 提示符运行pip uninstall pandas_profiling(假设您使用的是 Spyder,我猜这就是您的情况)/或命令提示符
  2. pip install https://github.com/pandas-profiling/pandas-profiling/archive/master.zip

如果您使用的是 Jupyter Notebook/Jupyter Lab 之类的东西,请务必重新启动内核并重新导入包。

我希望这有帮助。

于 2019-11-12T23:55:08.640 回答
0

pandas-profiling 的某些版本对我不起作用,我安装了 2.8.0 版本,它对我有用。

!pip install pandas-profiling==2.8.0
import numpy as np
import pandas as pd
import pandas_profiling as pp
df = pd.read_csv('/content/sample_data/california_housing_train.csv')
profile = df.profile_report(title = "Data Profiling Report")
profile.to_file("ProfileReportTest.html")
于 2021-03-05T22:18:43.920 回答
0

如果以上都不起作用,您可以通过在 read_csv 中将编码设置为 unicode_escape 来检查吗?这可能是由于您的专栏之一

 encoding = 'unicode_escape'
于 2021-06-09T18:04:53.007 回答
0

在 conda 环境中尝试

!pip install --user pandas-profiling
import pandas_profiling
data.profile_report()
于 2020-06-02T15:15:38.177 回答
0

我发现的唯一解决方法是我制作的 python 脚本是从命令提示符处执行并给出正确的输出,但代码仍然在 Spyder 中给出错误。

于 2019-07-25T02:03:28.900 回答