Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

no attribute named read_csv in pandas python

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]
like image 880
Pragna Debnath Avatar asked Jul 31 '15 18:07

Pragna Debnath


People also ask

Which of these is not an attribute of Read_csv in pandas?

Solution for the attributeerror: module 'pandas' has no attribute 'read_csv' The solution for module 'pandas' has no attribute 'read_csv' error is very simple. You have to rename the csv.py file or remove the csv.py file. First, try to rename the csv.py file and then run the code.

How does Python handle attribute errors?

Solution for AttributeError Errors and exceptions in Python can be handled using exception handling i.e. by using try and except in Python. Example: Consider the above class example, we want to do something else rather than printing the traceback Whenever an AttributeError is raised.

What is the return type of Read_csv in Python?

In this case, the Pandas read_csv() function returns a new DataFrame with the data and labels from the file data. csv , which you specified with the first argument. This string can be any valid path, including URLs.

What does CSV in Read_csv () stand for?

A comma-separated values (csv) file is returned as two-dimensional data structure with labeled axes. See also DataFrame.to_csv. Write DataFrame to a comma-separated values (csv) file. read_csv.


1 Answers

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.

like image 170
Shovalt Avatar answered Sep 20 '22 23:09

Shovalt