1

I am trying to read data from a csv file using pandas to perform regression and other statistical operations on the data but repeatedly get this error which wasn't present earlier.

  File "comp.py", line 1, in <module>
    import pandas as pd
  File "F:\Program Files (x86)\Python36-32\lib\site-packages\pandas\__init__.py", line 13, in <module>
    __import__(dependency)
  File "F:\Program Files (x86)\Python36-32\lib\site-packages\numpy\__init__.py", line 187, in <module>
    from .testing import Tester
  File "F:\Program Files (x86)\Python36-32\lib\site-packages\numpy\testing\__init__.py", line 10, in <module>
    from unittest import TestCase
  File "F:\Program Files (x86)\Python36-32\lib\unittest\__init__.py", line 64, in <module>
    from .main import TestProgram, main
  File "F:\Program Files (x86)\Python36-32\lib\unittest\main.py", line 4, in <module>
    import argparse
  File "F:\Program Files (x86)\Python36-32\lib\argparse.py", line 87, in <module>
    import copy as _copy
  File "F:\mathsassignment1\copy.py", line 2, in <module>
    data=pandas.read_csv("Output.csv")
AttributeError: module 'pandas' has no attribute 'read_csv'

This is my original code

import numpy as np
data=pandas.read_csv('Output.csv')

I have tried changing it to data=pandas.read_table("Output.csv",sep=',')

Still the exact same error message pops up

File "F:\mathsassignment1\copy.py", line 2, in <module>
    data=pandas.read_csv("Output.csv")
AttributeError: module 'pandas' has no attribute 'read_csv'

Yes, it still says

data=pandas.read_csv("Output.csv")

Even after trying to read another csv file with a different name the same error message is being

I have also tried reinstalling python, running it in Ubuntu instead of Windows, reinstalling pandas, Typing the same code again in another file . I don't have a file named pandas.py in my working directory. Please help out as soon as possible .Have wasted quite a few hours trying to figure out the problem.

lucifer091
  • 11
  • 2
  • Possible duplicate of [module 'pandas' has no attribute 'read\_csv](https://stackoverflow.com/questions/40554657/module-pandas-has-no-attribute-read-csv) – ktzr Feb 23 '19 at 19:39

3 Answers3

0

In one of the first lines, you typed in

import pandas as pd

and later

data=pandas.read_csv("Output.csv")

Instead, shouldn't it be

data=pd.read_csv("Output.csv")

because you imported pandas as pd?

tcglezen
  • 456
  • 1
  • 4
  • 12
0

can you rename your python file like comp.py to alptekin.py. and maybe you have some pandas.py file you are importing

0

With the imports below, the error message AttributeError: module 'pandas' has no attribute 'read_csv' disappears.

import pandas as pd  
import numpy as np   
import matplotlib.pyplot as plt
Bill Huang
  • 4,491
  • 2
  • 13
  • 31
kimm
  • 1
  • With a single "import pandas as pd" the error message appears. However why would the three imports not produce the same error message? – kimm Oct 27 '20 at 00:14