Post
Topic
Board Gambling discussion
Re: Women's Cricket Prediction & Discussion - T20 & ODI
by
UNTO Chain
on 27/02/2025, 08:27:37 UTC
```
import pandas as pd
from datetime import date, timedelta

def get_data():
    df = pd.read_csv('https://raw.githubusercontent.com/abhishekkrthakur/cricket-data/main/womens_cricket.csv')
   
    return df
   
df = get_data()

# Task 1: Find the number of matches played by India in both formats (T20 and ODIs) from January 2020 to December 2022.
print("Number of Matches Played By INDIA:")
india_matches_t20 = len(df[df['Team'] == 'India'][df['Format']=='Twenty20'])
india_matches_odi = len(df[df['Team'] == 'India'][df['Format']=='ODI'])

print(f"Matches In T20 : {india_matches_t20}")
print(f"Matches In ODI : {india_matches_odi}")

#Task 2: Which team has won maximum no.of matches between Jan-2019 to Dec-2022?
max_wins_team_name = max(set(list(df["Winner"])), key=list(df["Winner"]).count)
print(max_wins_team_name)

#Task 3: What is the highest score made by any player in this period?
highest_score_by_player = int(max([int(x.replace(',','')) for x in list(df['Score'])]))
print(highest_score_by_player)

#Task 4: How many times a match was tied or ended with No Result during this period?
no_result_count = sum( [x== "No result" for x in list(df["Result"])])
tied_match_count= sum( [x=="tie" for x in list(df["Result"])])
total_no_of_times_tie_or_nor = no_result_count + tied_match_count
print(total_no_of_times_tie_or_nor)

#Task 5: List down top five teams based on their win percentage. Also find out which country has more than one team participating.
win_percentage_df = df.groupby(['Country', 'Team']).agg({'Won': ['sum'], 'Lost':['sum']} ).reset_index()
win_percentage_df.columns=['country', 'team', 'won', 'lost']
win_percentage_df['Win %']= round(win_percentage_df.won/win_percentage_df.lost*100 ,2)
top_five_teams_with_win_percentages = win_percentage_df.sort_values(by='Win%', ascending=False).head().drop(columns={'won':'', 'lost':''})
teams_from_same_country=top_five_teams_with_win_percentages