jon
jon

Reputation: 771

Why is pandas not working and importing anymore?

I used this code before and it was working fine. Now no matter what I do pandas is not working. I tried uninstalling and reinstalling. I used the previous file that was working, none of it is working. Can you help me find out whats happening?
This code:

import pandas as pd

...
df = pd.read.csv('all_stocks_5yr')

causes the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-dc236c5894fa> in <module>
----> 1 df = pd.read.csv('all_stocks_5yr')

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas/__init__.py in __getattr__(name)
    261             return _SparseArray
    262 
--> 263         raise AttributeError(f"module 'pandas' has no attribute '{name}'")
    264 
    265 

AttributeError: module 'pandas' has no attribute 'read'

Upvotes: 0

Views: 182

Answers (3)

PRIN
PRIN

Reputation: 344

the command you need here is pd.read_csv('filepath'). You can learn more about it: here

Upvotes: 0

Kriti Pawar
Kriti Pawar

Reputation: 860

pandas has function read_csv() not read.csv().

try:

df = pd.read_csv('filename.csv')

Upvotes: 1

OlorinIstari
OlorinIstari

Reputation: 577

The command you are looking for is

pd.read_csv('filename')

Not

pd.read.csv('filename')

Upvotes: 1

Related Questions