In [1]:
import matplotlib.pylab as pylab
%matplotlib inline
pylab.rcParams['figure.figsize'] = 20, 14
pylab.rcParams['font.size'] = 18
import sys
sys.path.insert(0, '../triviz/')
from utils import *
from modele import *
In [2]:
T = TRICLAIRModele()
In [3]:
R=T.get_ranking_athletes(2014)
In [4]:
R.head()
Out[4]:
In [5]:
P=T.get_data_athlete(24880)
In [6]:
P
Out[6]:
In [7]:
L=T.get_list_triathlons(2014)
In [8]:
L.head()
Out[8]:
The variable links contains all the weblinks of the events held by the athlete in 2014.
In [9]:
links=sum([list(L['link'][(L['name']==course) & (L['format']==form)]) for course,form in zip(P['course'],P['format'])],[])
Warning: This list takes time to compute.
In [10]:
tris = [T.get_data_triathlon(l,2014) for l in links]
In [11]:
resultats = []
for trit,name,form in zip(tris,P['course'],P['format']):
trit = trit.dropna()
tri = pd.concat([trit.loc[:,:'Sexe'],trit.loc[:,'Scratch':].apply(normalize_col)],axis=1)
resultat = tri[(tri['Nom']=='RODRIGUEZ JOHAN') | (tri['Nom'] == 'JOHAN RODRIGUEZ')]
if resultat.empty:
pass
#print dir(resultat)
resultats.append(resultat.loc[:,'Scratch':])
resultats=pd.concat(resultats).reset_index()
In [12]:
resultats=resultats.rename(columns={'index':'Place'})
In [13]:
resultats=pd.concat([P['course'],resultats],axis=1)
In [14]:
resultats = resultats.drop('Place',axis=1)
resultats = resultats.set_index('course')
In [15]:
resultats
Out[15]:
In [18]:
resultats.plot(ylim=(90,150),kind='bar',rot=90)
plt.title('Season 2014 of Johan Rodriguez')
plt.xlabel('Time (% winner)')
Out[18]:
In [17]:
resultats.plot(kind='box',use_index=True)
plt.title('Season 2014 of Johan Rodriguez')
plt.ylabel('Time (% winner)')
Out[17]:
In [ ]: