ImportError when I try to import DataFrame from pandas

importerror: cannot import name 'abstractmethoderror'
importerror cannot import name timedelta
importerror cannot import name pandas_udf
cannot import name lmap from pandas/compat
pandas python
pandas documentation
cannot import name datetools
cannot import name np_version_under1p8

QUESTION : When i try to run "from pandas import read_csv" or "from pandas import DataFrame", I get an error saying "ImportError: cannot import name 'read_csv'" and "[![ImportError: cannot import name 'DataFrame'][1]][1]" respectively.


    from pandas import DataFrame
    from sklearn import datasets 
    iris = datasets.load_iris()
    data = pandas.DataFrame(iris)
    kfold = KFold(10, True, 1)
    for train, test in kfold.split(data):
print('train: %s, test: %s' % (data[train], data[test]))

WHAT I TRIED : I checked each and every import error question on stackoverflow and github but I couldn't figure out the solution. I don't have any other file named I tried uninstalling and reinstalling all the packages(like scipy, scikit-learn, numpy, pandas) I tried updating all the packages, but no luck Application specifications that i have - Windows 10, version 1803, Anaconda 4.5.8, spyder 3.3.0

Infact, none of my other code, which was running successfully previously, isn't executing because of these ImportErrors. Any help would be much appreciated. Thanks!

This is the result of "pip show pandas"

This is the result of "conda search -f pandas"

You have already imported DataFrame in statement from pandas import DataFrame.

So you don't need to use pandas.DataFrame, you can just use DataFrame instead.

But my suggestion will be using import pandas as pd, with this you can use all the submodules of pandas.

Use below code:

import pandas as pd
from sklearn import datasets 
iris = datasets.load_iris()
data = pd.DataFrame(iris)
kfold = KFold(10, True, 1)
for train, test in kfold.split(data):
    print('train: %s, test: %s' % (data[train], data[test]))

python, You have already imported DataFrame in statement from pandas import DataFrame . So you don't need to use pandas.DataFrame , you can just use DataFrame  There is an ImportError: cannot import name 'PandasError' when you use pandas version 0.20.1.. This is occurring on line 5 in from pandas.core.common import PandasError

You know what is wrong? Your file name This is funny but a tricky problem no one would easily notice. In fact, when you want to import a library, python first looks into the current folder, then all the python paths defined. Here, you try to import pandas, python first get your and look for DataFrame. But there is no DataFrame in it which can be imported.

Change your filename and that's it. In future, don't name your files with standard library names.

Error importing name 'DataFrame' from 'pandas.core.api' · Issue , ImportError: cannot import name 'DataFrame' from 'pandas.core.api' which may be throwing things off. Try renaming your file to  Code Sample, a copy-pastable example if possible With versions 0.20.0 and 0.20.1, I get the following error: import pandas Traceback (most recent call last): File "<stdin>", line 1,

If pandas and sklearn is correctly installed, this should work:

import pandas as pd
from sklearn import datasets 
from sklearn.model_selection import KFold
iris = datasets.load_iris()
data = pd.DataFrame(,columns = iris.feature_names)
kfold = KFold(10, True, 1)
for train, test in kfold.split(data):
    print('train: %s, test: %s' % (data.iloc[train], data.iloc[test]))

ImportError: cannot import name 'DataFrame' from 'pandas' · Issue , At execution time my exe fails on from pandas import DataFrame. I was using pandas 1.0 and I tried with pandas 0.25.2, but same error. When trying to install pandas 1.0.2 or newer versions on a docker, I run into the following import error: Traceback (most recent call last): File "<stdin>", line 1, Skip to content

IO Tools (Text, CSV, HDF5, …), Return a NumPy recarray instead of a DataFrame after parsing the data. 2.x or 3.x try: from io import BytesIO except ImportError: from cStringIO import StringIO  Installed pandas not able to import with: ImportError: DLL load failed: The specified module could not be found. As far as we know, this happens if you install with pip on Windows 32bit machines (if you have another case, please comment

What's new in 0.25.1 (August 21, 2019), In this case, import pandas failed due to an ImportError (:issue: 27575 ). Pandas Any subsequent attempt to use lzma methods will raise a RuntimeError . Bug in DataFrame arithmetic where missing values in results were  Hi, I just installed pandas_profiling via pip but it fails on import with the following error:

What's New, DataFrame.apply() was inconsistent when applying a ValueError when trying to merge on incompatible unnecessarily, potentially causing an import error on​  error: while concatenation in a dataframe using pandas! 49 minutes ago AttributeError: 'numpy.ndarray' object has no attribute 'append' 54 minutes ago Error: import No module name urllib2 1 hour ago

  • if you are importing only "DataFrame" from pandas. you should only be doing: data = DataFrame(iris) and not data = pandas.DataFrame(iris)
  • Check out this SO question.
  • I had checked it long back. I had python version 0.18 and upgraded to 0.22 but now I am getting "AttributeError: module 'pandas' has no attribute 'compat'" error!
  • @Smr how did you install pandas? conda install pandas ?
  • Yes conda install pandas, and then i did conda update pandas and then i tried pip install pandas==0.22 too
  • No luck. I tried running it as specified above but i get "AttributeError: module 'pandas' has no attribute 'core'" error.
  • This is the solution if case is NameError: name 'pandas' is not defined
  • I have already mentioned in my question that i DON'T HAVE any file. Also, this is the only error message it is showing. I have attached a screenshot
  • Can you get the trace of pip show pandas? and check which python too.
  • I have python 3.5.5 and I have edited my question to show the trace of "pip show pandas"
  • I actually cross-checked whether i have installed sklearn and pandas correctly. I even updated those packages. But i still encounter the same "AttributeError: module 'pandas' has no attribute 'core'" error
  • Which pandas version have you installed? check this @Smr
  • I have pandas (0.18.1)