df.profile_report()立即失败 导入pandas_profiling
该软件包已正确安装,因为我可以通过导入并仅使用构造函数ProfileReport(df)在Jupyter中生成报告。但是,语法df.profile_report()不起作用。
当我运行df.profile_report()时,出现以下错误消息:
```AttributeError Traceback (most recent call last)
in
----> 1 df.profile_report()
C:\Anaconda3\envs\quantecon\lib\site-packages\pandas\core\generic.py in getattr(self, name)
5065 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5066 return self[name]
-> 5067 return object.getattribute(self, name)
5068
5069 def setattr(self, name, value):
AttributeError: 'DataFrame' object has no attribute 'profile_report'
```
版本信息: 的Python 3.7.1 熊猫== 0.24.2
```import numpy as np
import pandas as pd
from pandas_profiling import ProfileReport
# The dataframe is the same as the tutorial example given by the author.
df = pd.DataFrame(np.random.rand(100, 5), columns=['a', 'b', 'c', 'd', 'e'])
df.profile_report() # this fails.```
我还尝试了其他有效的方法,如下所示: 从pandas_profiling导入ProfileReport ...创建数据框df的步骤 ProfileReport(df)
至少使用构造函数ProfileReport(df)至少可以在Jupyter Notebook中获得一份报告。因此,我知道该软件包已安装且正在运行。但是,获取报告的object.method()路由无效。但是许多其他方法都依赖于object.method()语法。
```import numpy as np
import pandas as pd
from pandas_profiling import ProfileReport
# The dataframe is the same as the tutorial example given by the author.
df = pd.DataFrame(
np.random.rand(100, 5),
columns=['a', 'b', 'c', 'd', 'e']
)
df.profile_report() # this fails.
ProfileReport(df) # this works, but `df.profile_report()` does not work.
```
我猜怎么了...?
由于pandas错误是针对Pandas Core DataFrame的“ generic.py”引用,而错误是“ no attribute'profile_report'”,因此可能是装饰器包装了dataframe对象并对其进行了修改以赋予它额外的属性.profile_report()的方法??这是我的猜测,我不知道是什么原因引起的错误,因为当我“偷偷摸摸”并直接使用报表构造函数时,该错误起作用了,我无法使用其他依赖的方法关于object.method()语法。
答案 0 :(得分:1)
.profile_report()
版本2中引入了pandas_profiling
语法。
您可以通过pip install pandas-profiling
来安装此版本。
编辑
导入软件包的方法是:
import pandas_profiling
与您当前的方法相反
from pandas_profiling import ProfileReport
答案 1 :(得分:1)
尝试一下:
Performing hot reload...
Syncing files to device Android SDK built for x86...
Reloaded 3 of 474 libraries in 1 272ms.
I/BiChannelGoogleApi(17924): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzao@711d32a
W/DynamiteModule(17924): Local module descriptor class for com.google.firebase.auth not found.
I/FirebaseAuth(17924): [FirebaseAuth:] Preparing to create service connection to gms implementation
I/art (17924): Background sticky concurrent mark sweep GC freed 20942(1058KB) AllocSpace objects, 0(0B) LOS objects, 31% free, 2MB/3MB, paused 29.893ms total 107.321ms
D/FirebaseAuth(17924): Notifying id token listeners about user ( YT5FSoTNCJdlUQb2msW0S01VZSf1 ).
D/FirebaseAuth(17924): Notifying auth state listeners about user ( YT5FSoTNCJdlUQb2msW0S01VZSf1 ).
I/flutter (17924): NoSuchMethodError: Class 'AuthResult' has no instance getter 'email'.
I/flutter (17924): Receiver: Instance of 'AuthResult'
I/flutter (17924): Tried calling: email