Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import numpy as np
- results = []
- def readAll():
- global results
- groups = "ABCDEF"
- frames = []
- for g in groups:
- one = pd.read_csv(f'{g}.csv', header=0, sep=',')
- one['group'] = [g] * len(one)
- one.fillna('', inplace=True)
- frames += [one]
- results = pd.concat(frames)
- def listGoals(s):
- a = s.strip().split(';')
- if len(a) == 0:
- return []
- return sorted([int(x) for x in a if len(x) > 0])
- results['home_team_goal_timings'] = results['home_team_goal_timings'].apply(listGoals)
- results['away_team_goal_timings'] = results['away_team_goal_timings'].apply(listGoals)
- def userAsk():
- # team = input("Название команды: ")
- team = "Russia"
- print(f"Статистика для команды {team}: ")
- cntTie = cntWin = cntAll = 0
- goal1 = goal2 = 0
- for index, row in results[ (results['home_team_name'] == team) | (results['away_team_name'] == team) ].iterrows():
- cntAll += 1
- if row['home_team_name'] == team:
- goal1 += int(row['home_team_goal_count'])
- goal2 += int(row['away_team_goal_count'])
- if int(row['home_team_goal_count']) > int(row['away_team_goal_count']):
- cntWin += 1
- else:
- goal1 += int(row['away_team_goal_count'])
- goal2 += int(row['home_team_goal_count'])
- if int(row['home_team_goal_count']) < int(row['away_team_goal_count']):
- cntWin += 1
- if int(row['home_team_goal_count']) == int(row['away_team_goal_count']):
- cntTie += 1
- print("Количество сыгранных матчей:", cntAll)
- print("Количество побед:", cntWin)
- print("Количество ничьих:", cntTie)
- print("Количество поражений:", cntAll - cntWin - cntTie)
- print("Количество забитых мячей:", goal1)
- print("Количество пропущенных мячей:", goal2)
- if __name__ == '__main__':
- readAll()
- userAsk()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement