Skip to content
SailGP datasets analysis
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
df = pd.read_csv('sailgp_sgp_sail_history.csv')
df.head()
df.dtypes
df['wind_speed_int']=df.WIND_SPEED.astype('int32')
data_per_ws = df.groupby('wind_speed_int').BOAT_SPEED.count()
data_per_ws.plot()
plt.title('Number of data plot per wind speed value')
plt.xlabel("Wind speed value (kts)")
plt.ylabel("Number of values")
plt.show()
df.sort_values('WIND_ANGLE', inplace=True)
df.reset_index(drop=True, inplace=True)
df
list_wind_values = list(pd.unique(df.wind_speed_int))
list_wind_values.sort()
plt.figure(figsize=(20, 10), dpi=80)
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
for w in [5,10,15,20,25]:
selection= (df.wind_speed_int == w)
df_sel = df[selection]
ax.plot(df_sel.WIND_ANGLE*np.pi/180, df_sel.BOAT_SPEED, label="Wind :"+str(w)+" kts.")
#ax.set_rticks([2, 4,6,8,10]) # Less radial ticks
ax.set_rlabel_position(-22.5) # Move radial labels away from plotted line
ax.grid(True)
plt.legend(loc='best', bbox_to_anchor=(1, 0.8, 0.5, 0.5))
ax.set_title("A line plot on a polar axis", va='bottom')
plt.show()
df_sel
df_strm_pivot = pd.read_csv('sailgp_sgp_strm_pivot.csv')
df_strm_pivot.head(20)
#boat_select = df_strm_pivot['B_NAME'] == FRA
dfposition=df_strm_pivot[['TIME_GRP','B_NAME','LATITUDE', 'LONGITUDE', 'BDE_LEG_NUM_UNK']]
dfposition.sort_values('TIME_GRP', inplace=True)
dfposition = dfposition[dfposition.B_NAME.isin(['FRA','NZL'])]
dfposition.head(20)
plt.figure(figsize=(20, 10), dpi=80)
fig, ax = plt.subplots()
boat_list = list(dfposition.B_NAME.unique())
for boat in boat_list:
selection= ((dfposition.B_NAME == boat) & (dfposition.TIME_GRP >= 0) & (dfposition.BDE_LEG_NUM_UNK == 2))
df_sel = dfposition[selection]
ax.plot(df_sel.LATITUDE, df_sel.LONGITUDE, label="Team :"+str(boat), marker='o', markevery=[0])
ax.grid(True)
plt.legend(loc='best', bbox_to_anchor=(1, 0.8, 0.5, 0.5))
ax.set_title("Race replay: "+boat_list[0]+" VS "+boat_list[1], va='bottom')
plt.show()