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]
There was a file named
pandas.py
(and/orpandas.pyc
) in the working directory, which was imported instead of the pandas library. Removing or renaming the file/s solved the problem.More likely you have not installed pandas correctly . For me installing pandas correctly got me through this error . Here goes the installation .....
This will install a fast numeric processing library (numpy) and a tool required in the pandas build process (cython).
Test numpy
Open up a Python prompt by running the following:
At the prompt, type the following:
You should see a number like "1.6.1" or higher.
Test cython
Open up a Python prompt by running the following:
At the prompt, type the following (capitalization matters!):
You should see a number like "0.15.1" or higher.
Download pandas
We recommend storing pandas in a directory called ''projects'' in your user directory. To do that, run the following commands:
You will see git download pandas. Once the download finishes, and you get your prompt back, proceed to the next step.
Build pandas
To build pandas, you have to run the following two commands:
This will take about 2 minutes. Once it is finished, run this command:
This will also take about 2 minutes.
Test pandas
To make sure it has built properly, run the following command inside the pandas directory:
Within this python prompt, type:
You should see this version number: '''0.10.0b1'''. Done hope this rids you off the error .