Guest User

Untitled

a guest
May 25th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. # Copyright: slavisa 20/09/2017
  2. # name: kvote za ATP
  3. # source: www.tennis-data.co.uk/alldata.php
  4. #-------------------------------------------------------------------------------
  5.  
  6. import pandas as pd
  7. import numpy as np
  8. import matplotlib.pyplot as plt
  9. from math import sqrt
  10.  
  11. from collections import Counter
  12. import warnings
  13. import glob
  14.  
  15. '''
  16. www.tennis-data.co.uk/alldata.php gives us the Tennis.xls file
  17. '''
  18.  
  19. df = pd.read_excel('Tennis.xls')
  20. #df(columns =['Surface', 'Winner', 'Loser', 'AvgW', 'AvgL']), proveri kako ide samo include!
  21.  
  22. Rival_1 ='Pouille L.' # type a name
  23. Rival_2 ='Sock J.' # type a name
  24. Surface ='Hard' # name the surface
  25.  
  26. df.drop(['ATP', 'Location', 'Tournament',
  27. 'Date', 'Series', 'Court', 'Round',
  28. 'Best of', 'WPts', 'LPts', 'W1',
  29. 'L1', 'WRank', 'LRank', 'W2', 'L2',
  30. 'W3', 'L3', 'W4', 'L4', 'W5', 'L5',
  31. 'Wsets','Lsets', 'Comment', 'B365W',
  32. 'B365L', 'EXW', 'EXL', 'LBW', 'LBL',
  33. 'PSW', 'PSL', 'MaxW', 'MaxL'],1 , inplace = True)
  34.  
  35.  
  36. df.dropna
  37. df.replace('N/A', -99999)
  38.  
  39. DF = np.array (df) # i[3] je pobednik a i[4] je porazeni
  40.  
  41. try:
  42. uk1 = 0
  43. brojac1 = 0
  44. for i in DF:
  45. if i[0] == Surface and i[1] == Rival_1 and i[2] == Rival_2:
  46. uk =+ i[3]
  47. brojac1 =+ 1
  48. srednja_kvota1 = float(uk/brojac1)
  49. except:
  50. srednja_kvota1 = 0
  51.  
  52. try:
  53. uk2 = 0
  54. brojac2 = 0
  55. for i in DF:
  56. if i[0] == Surface and i[1] == Rival_2 and i[2] == Rival_1:
  57. uk2 =+ i[4]
  58. brojac2 =+ 1
  59. srednja_kvota2 = float(uk2/brojac2)
  60. except:
  61. srednja_kvota2 = 0
  62.  
  63. try:
  64. if srednja_kvota1 == 0:
  65. srednja_kvota = srednja_kvota2
  66.  
  67. elif srednja_kvota2 == 0:
  68. srednja_kvota = srednja_kvota1
  69. else:
  70. srednja_kvota = (srednja_kvota1+srednja_kvota2)/2
  71.  
  72. print ('ocekivana kvota na '+ Rival_1+ ' protiv '+ Rival_2)
  73. print (srednja_kvota)
  74. except:
  75. print ('No Data')
Add Comment
Please, Sign In to add comment