BrokenStrings
BrokenStrings

Reputation: 1

Fixing library import for python

I have trouble running this simple code chunk

#!/usr/bin/python

from pandas import read_csv


url = "/Users/maya/Documents/UPEM/Cours/M2/Big Data/ML_Test/base_earthquake.csv"
quakes = pd.read_csv(url)


print(quakes.columns)

I get this error


Traceback (most recent call last):
  File "./ml_test.py", line 4, in <module>
    import pandas as pd
ImportError: No module named pandas

I tried this command

pip install --upgrade pandas

but it does not seem to work

Upvotes: 0

Views: 65

Answers (1)

Nestor
Nestor

Reputation: 73

If you use

from pandas import read_csv

then you should call it like:

quakes = read_csv(url)

otherwise do

import pandas as pd

and it should work

Upvotes: 1

Related Questions