Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Copyright: slavisa 20/09/2017
- # name: kvote za ATP
- # source: www.tennis-data.co.uk/alldata.php
- #-------------------------------------------------------------------------------
- import pandas as pd
- import numpy as np
- import matplotlib.pyplot as plt
- from math import sqrt
- from collections import Counter
- import warnings
- import glob
- '''
- www.tennis-data.co.uk/alldata.php gives us the Tennis.xls file
- '''
- df = pd.read_excel('Tennis.xls')
- #df(columns =['Surface', 'Winner', 'Loser', 'AvgW', 'AvgL']), proveri kako ide samo include!
- Rival_1 ='Pouille L.' # type a name
- Rival_2 ='Sock J.' # type a name
- Surface ='Hard' # name the surface
- df.drop(['ATP', 'Location', 'Tournament',
- 'Date', 'Series', 'Court', 'Round',
- 'Best of', 'WPts', 'LPts', 'W1',
- 'L1', 'WRank', 'LRank', 'W2', 'L2',
- 'W3', 'L3', 'W4', 'L4', 'W5', 'L5',
- 'Wsets','Lsets', 'Comment', 'B365W',
- 'B365L', 'EXW', 'EXL', 'LBW', 'LBL',
- 'PSW', 'PSL', 'MaxW', 'MaxL'],1 , inplace = True)
- df.dropna
- df.replace('N/A', -99999)
- DF = np.array (df) # i[3] je pobednik a i[4] je porazeni
- try:
- uk1 = 0
- brojac1 = 0
- for i in DF:
- if i[0] == Surface and i[1] == Rival_1 and i[2] == Rival_2:
- uk =+ i[3]
- brojac1 =+ 1
- srednja_kvota1 = float(uk/brojac1)
- except:
- srednja_kvota1 = 0
- try:
- uk2 = 0
- brojac2 = 0
- for i in DF:
- if i[0] == Surface and i[1] == Rival_2 and i[2] == Rival_1:
- uk2 =+ i[4]
- brojac2 =+ 1
- srednja_kvota2 = float(uk2/brojac2)
- except:
- srednja_kvota2 = 0
- try:
- if srednja_kvota1 == 0:
- srednja_kvota = srednja_kvota2
- elif srednja_kvota2 == 0:
- srednja_kvota = srednja_kvota1
- else:
- srednja_kvota = (srednja_kvota1+srednja_kvota2)/2
- print ('ocekivana kvota na '+ Rival_1+ ' protiv '+ Rival_2)
- print (srednja_kvota)
- except:
- print ('No Data')
Add Comment
Please, Sign In to add comment