Importing Pandas gives error AttributeError: module 'pandas' has no attribute 'core' in iPython Notebook

前端 未结 19 729
夕颜
夕颜 2020-11-30 09:50

I am running a iPython notebook via the Anaconda Navigator app (version 1.1.0). When I want to import pandas it gives me a strange error. I thought the Anaconda app included

相关标签:
19条回答
  • 2020-11-30 10:08

    You are getting this is because you are using a Anaconda distribution of Jupyter notebook. So just do conda install pandas restart your jupyter notebook and rerun your cell. It should work. If you are trying this on a Virtual Env try this

    1. conda create -n name_of_my_env python This will create a minimal environment with only Python installed in it. To put your self inside this environment run:

    2 source activate name_of_my_env On Windows the command is: activate name_of_my_env The final step required is to install pandas. This can be done with the following command:

    conda install pandas To install a specific pandas version:

    conda install pandas=0.20.3

    To install other packages, IPython for example:

    conda install ipython To install the full Anaconda distribution:

    conda install anaconda

    If you need packages that are available to pip but not conda, then install pip, and then use pip to install those packages:

    conda install pip pip install django Installing from PyPI pandas can be installed via pip from PyPI.

    pip install pandas Installing with ActivePython

    Hope this helps.

    0 讨论(0)
  • 2020-11-30 10:09

    I can confirm this issue is due to pandas 0.23.

    Uninstall and then reinstall 0.22.

    pip uninstall pandas
    pip install pandas==0.22
    

    Hope this could solve the problem.

    0 讨论(0)
  • 2020-11-30 10:13

    There is an other weird reason this happens. If you have a file called pandas.py or a directory called pandas in the same or nested levels, that library is used instead and fails to work. Rename the folder and restart the env and it started working. Faced this

    0 讨论(0)
  • 2020-11-30 10:15

    "Have you tried turning it off and on again?" (Roy of The IT crowd)

    This happened to me today, which is why I ended up to this page. Seeing that error was weird since, recently, I have not made any changes in my Python environment. Interestingly, I observed that if I open a new notebook and import pandas I would not get the same error message. So, I did shutdown the troublesome notebook and started it again and voila it is working again!

    Even though this solved the problem (at least for me), I cannot readily come up with an explanation as to why it happened in the first place!

    0 讨论(0)
  • 2020-11-30 10:17
    1. Press Ctrl+C to shut down the jupyter notebook, close all jupyter notebook windows
    2. Reopen it by typing jupyter notebook in cmd prompt.
    0 讨论(0)
  • 2020-11-30 10:18

    I got the same error for pandas latest version. Then saw this warning

    FutureWarning: 'pandas.tools.plotting.scatter_matrix' is deprecated, import 'pandas.plotting.scatter_matrix' instead.

    This shall work for you.

    0 讨论(0)
提交回复
热议问题