Jovian
⭐️
Sign In
In [2]:
!pip install jovian --upgrade --quiet
In [3]:
!pip install pandas --upgrade
Requirement already up-to-date: pandas in /srv/conda/envs/notebook/lib/python3.7/site-packages (1.1.2) Requirement already satisfied, skipping upgrade: pytz>=2017.2 in /srv/conda/envs/notebook/lib/python3.7/site-packages (from pandas) (2020.1) Requirement already satisfied, skipping upgrade: python-dateutil>=2.7.3 in /srv/conda/envs/notebook/lib/python3.7/site-packages (from pandas) (2.8.1) Requirement already satisfied, skipping upgrade: numpy>=1.15.4 in /srv/conda/envs/notebook/lib/python3.7/site-packages (from pandas) (1.19.2) Requirement already satisfied, skipping upgrade: six>=1.5 in /srv/conda/envs/notebook/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
In [3]:
import pandas as pd
In [4]:
matches_raw_df = pd.read_csv('matches.csv')
In [5]:
matches_raw_df
Out[5]:
In [6]:
matches_raw_df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 756 entries, 0 to 755 Data columns (total 18 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 id 756 non-null int64 1 season 756 non-null int64 2 city 749 non-null object 3 date 756 non-null object 4 team1 756 non-null object 5 team2 756 non-null object 6 toss_winner 756 non-null object 7 toss_decision 756 non-null object 8 result 756 non-null object 9 dl_applied 756 non-null int64 10 winner 752 non-null object 11 win_by_runs 756 non-null int64 12 win_by_wickets 756 non-null int64 13 player_of_match 752 non-null object 14 venue 756 non-null object 15 umpire1 754 non-null object 16 umpire2 754 non-null object 17 umpire3 119 non-null object dtypes: int64(5), object(13) memory usage: 106.4+ KB
In [7]:
import jovian
In [ ]:
jovian.commit(files = ['matches.csv'])
[jovian] Attempting to save notebook..
In [10]:
matches_raw_df.groupby('season').season.count()
Out[10]:
season
2008    58
2009    57
2010    60
2011    73
2012    74
2013    76
2014    60
2015    59
2016    60
2017    59
2018    60
2019    60
Name: season, dtype: int64
In [1]:
matches_raw_df.groupby('season').toss_decision.value_counts() / matches_raw_df.groupby('season').season.count() * 100
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-1-d61fbc1666c7> in <module> ----> 1 matches_raw_df.groupby('season').toss_decision.value_counts() / matches_raw_df.groupby('season').season.count() * 100 NameError: name 'matches_raw_df' is not defined
In [37]:
matches_raw_df[matches_raw_df.season >= 2019].toss_winner.value_counts() / (matches_raw_df[matches_raw_df.season >= 2019].team2.value_counts() + matches_raw_df[matches_raw_df.season >= 2019].team1.value_counts()) * 100

Out[37]:
Chennai Super Kings            70.588235
Delhi Capitals                 62.500000
Kings XI Punjab                42.857143
Kolkata Knight Riders          35.714286
Mumbai Indians                 50.000000
Rajasthan Royals               78.571429
Royal Challengers Bangalore    28.571429
Sunrisers Hyderabad            26.666667
dtype: float64
In [13]:
(matches_raw_df.team2.value_counts() + matches_raw_df.team1.value_counts())

Out[13]:
Chennai Super Kings            164
Deccan Chargers                 75
Delhi Capitals                  16
Delhi Daredevils               161
Gujarat Lions                   30
Kings XI Punjab                176
Kochi Tuskers Kerala            14
Kolkata Knight Riders          178
Mumbai Indians                 187
Pune Warriors                   46
Rajasthan Royals               147
Rising Pune Supergiant          16
Rising Pune Supergiants         14
Royal Challengers Bangalore    180
Sunrisers Hyderabad            108
dtype: int64
In [15]:
matches_raw_df.winner.value_counts() / (matches_raw_df.team2.value_counts() + matches_raw_df.team1.value_counts()) * 100
Out[15]:
Chennai Super Kings            60.975610
Deccan Chargers                38.666667
Delhi Capitals                 62.500000
Delhi Daredevils               41.614907
Gujarat Lions                  43.333333
Kings XI Punjab                46.590909
Kochi Tuskers Kerala           42.857143
Kolkata Knight Riders          51.685393
Mumbai Indians                 58.288770
Pune Warriors                  26.086957
Rajasthan Royals               51.020408
Rising Pune Supergiant         62.500000
Rising Pune Supergiants        35.714286
Royal Challengers Bangalore    46.666667
Sunrisers Hyderabad            53.703704
dtype: float64
In [38]:
jovian.commit()
[jovian] Attempting to save notebook.. [jovian] Updating notebook "srijansrj5901/ipl-matches-data-analysis" on https://jovian.ml/ [jovian] Uploading notebook.. [jovian] Capturing environment.. [jovian] Committed successfully! https://jovian.ml/srijansrj5901/ipl-matches-data-analysis
In [ ]:
jovian.commit(files = ['matches.csv'])
[jovian] Attempting to save notebook..
In [ ]: