1. Import data (CSV format) into Jupyter
Import Pandas as PD
Import Matplotlib.pyplot as Plt
Filename= ' Data.csv '
Raw=pd.read_csv filename
Print (Raw.shape)
Raw.head () #打印前几行
2. Remove null values for a column
Kobe=raw[pd.notnull (raw[' Shot_made_flag ')]
Print (Kobe.shape)
3. Drawing with Matplotlib
alpha=0.02# point transparency, the smaller the more transparent
Plt.figure (figsize= (10,10))
Plt.subplot (121) #一行两列, the first one
Plt.scatter (kobe.loc_x,kobe.loc_y,color= ' Blue ', Alpha=alpha) #散点图
Plt.title (' loc_x and Loc_y ')
Plt.subplot (122) #一行两列, the first one
Plt.scatter (kobe.loc_x,kobe.loc_y,color= ' green ', Alpha=alpha) #散点图
Plt.title (' Lat and lon ')
4. Print unique values
Print (Kobe.action_type.unique ())
Print (Kobe.combined_shot_type.unique ())
Print (Kobe.shot_type.unique ())
Print (Kobe.shot_type.value_counts ()) #相同值出现次数
5.
Python data analysis-kobe Bryan Career data reading and analysis