JavaScript
x
2
1
df = pd.read_csv( "https://raw.githubusercontent.com/Apress/data-analysis-and-visualization-using-python/master/Ch07/Salaries.csv")
2
The error I get is: bash: syntax error near unexpected token `(‘
When I switch it to [] is get:
JavaScript
1
5
1
df = pd.read_csv["https://raw.githubusercontent.com/Apress/data-analysis-and-visualization-using-python/master/Ch07/Salaries.csv"]
2
3
Filesystem 1K-blocks Used Available Use% Mounted on
4
df: =: can't find mount point
5
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:
JavaScript
1
3
1
import pandas as pd
2
df = pd.read_csv("https://raw.githubusercontent.com/Apress/data-analysis-and-visualization-using-python/master/Ch07/Salaries.csv")
3
Produces
JavaScript
1
16
16
1
>>> df
2
rank discipline phd service sex salary
3
0 Prof B 56 49 Male 186960
4
1 Prof A 12 6 Male 93000
5
2 Prof A 23 20 Male 110515
6
3 Prof A 40 31 Male 131205
7
4 Prof B 20 18 Male 104800
8
..
9
73 Prof B 18 10 Female 105450
10
74 AssocProf B 19 6 Female 104542
11
75 Prof B 17 17 Female 124312
12
76 Prof A 28 14 Female 109954
13
77 Prof A 23 15 Female 109646
14
15
[78 rows x 6 columns]
16