no attribute named read_csv in pandas python

Pragna Debnath picture Pragna Debnath · Jul 31, 2015 · Viewed 15.4k times · Source

I am new to machine learning and am creating a dataset using pandas in Python. I looked up a tutorial and was just trying out a basic code for creating a dataframe, but I keep getting the following trace-back:

AttributeError: 'module' object has no attribute 'read_csv'

I have saved the csv file in the csv(comma delimited) formatfrom Excel 13. Here's my code:

    import pandas
    import csv

    mydata = pandas.read_csv('foo.csv')
    target = mydata["Label"]

    data = mydata.ix[:,:-1]

Answer

Shovalt picture Shovalt · Jan 24, 2017

There was a file named pandas.py (and/or pandas.pyc) in the working directory, which was imported instead of the pandas library. Removing or renaming the file/s solved the problem.