I'm currently trying to learn Python through coursera and I'm trying to run the code but I'm running into an error when I try to install nba_api. Below I have pasted my code
!pip install nba_api
# I get an 'invalid syntax error' here ^^
import pandas as pd
import matplotlib.pyplot as plt
x={'a':[11,21,31],'b':[12,22,32]}
print(x)
df=pd.DataFrame(x)
print(type(df))
print(df.head())
from nba_api.stats.static import teams
import matplotlib.pyplot as plt
Any ideas what I'm doing wrong/missing here?
!
is a shorthand for calling out to the shell that is only in the REPL. You can't use this in Python files.Instead you should put your code in a package and have a dependency on nba_api, when someone installs your package, nba_api package would also be installed.