Tristan Sun
Tristan Sun

Reputation: 299

Python cannot import CSV using DataFrame

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 !!!

Upvotes: 0

Views: 1056

Answers (1)

DSM
DSM

Reputation: 353459

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.

Upvotes: 3

Related Questions