Search code examples
pythonpandasindexingkeyerrorpandas-profiling

Pandas Profiling - KeyError: 'Requested level (var1) does not match index name (None)'


I am receiving KeyError: 'Requested level (var1) does not match index name (None)'. , on running the below code.

pandas_profiling version = 2.8.0

Code:

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

Error Message:

~\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)'

I am not sure how to fix this? Could anyone help with the same?

Thank you for your help in advance!


Solution

  • I saw this error when I was running pandas-profiling version 2.3.0, but it went away after upgrading to version 2.8.0. I don't know if you're using pycaret, as well, but when I installed pycaret verion 1.0.0 it downgraded the version of pandas-profiling from 2.8.0 to 2.3.0. I confirmed this with a "pip freeze/conda list" after installing pycaret.

    Unfortunately, this means that I'm only able to have pandas-profiling v2.8.0 OR pycaret v1.0.0 installed, so I'm using two separate virtualenvs to separapte these two packages. But I no longer see this error.