0

I am using Pandas to import some csv file into Python.

my code is:

import pandas as pd  
data_df = pd.read_csv('highfrequency2.csv')
print data_df.head()

but there is always an error message:

**Traceback (most recent call last):
  File "G:\Python\sdfasdfasdfasdfasdf.py", line 7, in <module>
import pandas as pd
  File "G:\Python\pandas.py", line 9, in <module>
from pandas import DataFrame
ImportError: cannot import name DataFrame**

Can some one figure out why ? Many thanks !!!

20
  • Is there a reason you need to import it?, if you remove that line does it work? Commented Apr 19, 2015 at 15:44
  • Could you specify pandas and python version? Commented Apr 19, 2015 at 15:47
  • @zom-pro Python 2.72. I am scripting under Spyder. How can I see the pandas version ? Commented Apr 19, 2015 at 15:49
  • @EdChum sorry, remove which line ? Commented Apr 19, 2015 at 15:49
  • from pandas import DataFrame, you can get pandas version using print(pd.__version__) Commented Apr 19, 2015 at 15:50

1 Answer 1

3

It look like you've called one of your own programs pandas:

G:\Python\pandas.py

So this is the one Python is trying to import, and the one which doesn't have a DataFrame object.

Rename your program, delete any cached objects (pandas.pyc or pandas.pyo), and restart your Python interpreter.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.