df = pd.read_csv( "https://raw.githubusercontent.com/Apress/data-analysis-and-visualization-using-python/master/Ch07/Salaries.csv")
The error I get is: bash: syntax error near unexpected token `(‘
When I switch it to [] is get:
df = pd.read_csv["https://raw.githubusercontent.com/Apress/data-analysis-and-visualization-using-python/master/Ch07/Salaries.csv"] Filesystem 1K-blocks Used Available Use% Mounted on df: =: can't find mount point
I’m unsure if I’m missing code or entering it incorrectly.
Advertisement
Answer
You’re trying to run python in the shell instead of in python.
Within the shell enter py
, python
or python3
.
From there, do your normal python commands:
import pandas as pd df = pd.read_csv("https://raw.githubusercontent.com/Apress/data-analysis-and-visualization-using-python/master/Ch07/Salaries.csv")
Produces
>>> df rank discipline phd service sex salary 0 Prof B 56 49 Male 186960 1 Prof A 12 6 Male 93000 2 Prof A 23 20 Male 110515 3 Prof A 40 31 Male 131205 4 Prof B 20 18 Male 104800 .. ... ... ... ... ... ... 73 Prof B 18 10 Female 105450 74 AssocProf B 19 6 Female 104542 75 Prof B 17 17 Female 124312 76 Prof A 28 14 Female 109954 77 Prof A 23 15 Female 109646 [78 rows x 6 columns]