no attribute named read_csv in pandas python

15,965

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.

Share:
15,965
Pragna Debnath
Author by

Pragna Debnath

Updated on July 26, 2022

Comments

  • Pragna Debnath
    Pragna Debnath almost 2 years

    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]