'ImportError: cannot import name 'ABCIndexClass' from 'pandas.core.dtypes.generic'

I have this output :

[Pandas-profiling] ImportError: cannot import name 'ABCIndexClass' from 'pandas.core.dtypes.generic'

when trying to import pandas-profiling in this fashion :

from pandas_profiling import ProfileReport

It seems to import pandas-profiling correctly but struggles when it comes to interfacing with pandas itself. Both libraries are currently up to date through conda. It doesn't seem to match any of the common problems associated with pandas-profiling as per their documentation, and I can't seem to locate a more general solution of importing the name ABCIndexClass.

Thanks



Solution 1:[1]

Thanks to the @aflyingtoaster's answer, the following workaround has worked fine for me:

  1. Edit the file "~/[your_conda_env_path]/lib/site-packages/visions/dtypes/boolean.py"
  2. Find the row "from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries" and just replace ABCIndexClass for ABCIndex.
  3. Save the boolean.py file and enjoy your report!

Solution 2:[2]

Pandas v1.3 renamed the ABCIndexClass to ABCIndex. The visions dependency of the pandas-profiling package hasn't caught up yet, and so throws an error when it can't find ABCIndexClass. Downgrading pandas to the 1.2.x series will resolve the issue.

Alternatively, you can just wait for the visions package to be updated.

Solution 3:[3]

ABCIndexclass to ABCIndex

go to user>annaconda 3>Lib> site package > visions > dtypes > boolean.py

open boolean.py in words

go to line where it says ABCIndexclass and change it to ABCIndex

Solution 4:[4]

If you are using Anaconda distribution, another solution is to first update

conda update --all

Then delete every folder related to pandas_profiling at ~/[your_conda_env_path]/Lib/site-packages/. For example:

  • pandas_profiling
  • pandas_profiling-1.4.1-py2.7.egg-info
  • ...

Later, use this CLI to install the package

conda install -c conda-forge pandas-profiling

It worked for me while using https://repo.anaconda.com/archive/Anaconda3-2021.11-Windows-x86_64.exe

Solution 5:[5]

For MacOS users, this was the path I needed:

/opt/anaconda3/pkgs/visions-0.5.0-pyhd3eb1b0_0/site-packages/visions/dtypes/boolean.py

Removing 'index' from 'ABCClassIndex' worked for me as well.

Solution 6:[6]

The issue is with pandas 1.3.x.

Alternatively downgrade the pandas package to 1.2.x.

You can do that from Anaconda Navigator. Go to Environments and downgrade pandas package.

This worked for me.

Solution 7:[7]

I had this issue in colab and none of the previous answers covered that environment, so I'd like to share what works for me - !pip install https://github.com/ydataai/pandas-profiling/archive/master.zip which just simply install the latest pandas-profiling instead of the default one or 2.7.1 etc

Solution 8:[8]

Worked for me as well. I'm on linux-mint and need a slightly different path to find the file (similar as for mac user's as stated above)

[where is anaconda installation]/.conda/pkgs/visions-0.4.4-pyh9f0ad1d_0/site-packages/visions/dtypes/boolean.py

I'm using the VScodium IDE. Restarted the sesion and worked instantly :)

Solution 9:[9]

Just installed the "visions" package and it fixed for me.

pip install visions

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 aflyingtoaster
Solution 3 Dhaval Desai
Solution 4 juanbretti
Solution 5 jmoerdyk
Solution 6
Solution 7 uniquegino
Solution 8 Emiliano
Solution 9 user6397960