2

我正在接收 KeyError: 'Requested level (var1) does not match index name (None)'. ,在运行下面的代码。

pandas_profiling 版本 = 2.8.0

代码:

Profile = df_NYC.profile_report(title = "NYC Flight Data Profiling before Pre-processing")

错误信息:

~\anaconda3\lib\site-packages\pandas\core\indexes\base.py in _validate_index_level(self, level)
   1414         elif level != self.name:
   1415             raise KeyError(
-> 1416                 f"Requested level ({level}) does not match index name ({self.name})"
   1417             )
   1418 
KeyError: 'Requested level (var1) does not match index name (None)'

我不知道如何解决这个问题?任何人都可以帮忙吗?

提前谢谢你的帮助!

4

1 回答 1

3

我在运行 pandas-profiling 2.3.0 版时看到了这个错误,但升级到 2.8.0 版后它就消失了。我不知道你是否也在使用 pycaret,但是当我安装 pycaret 版本 1.0.0 时,它会将 pandas-profiling 的版本从 2.8.0 降级到 2.3.0。安装 pycaret 后,我​​通过“pip freeze/conda list”确认了这一点。

不幸的是,这意味着我只能安装 pandas-profiling v2.8.0 或 pycaret v1.0.0,所以我使用两个单独的 virtualenvs 来分离这两个包。但我不再看到这个错误。

于 2020-07-16T16:15:23.970 回答