!pip install jovian --upgrade --quiet
!pip install pandas --upgrade
Collecting pandas
Downloading pandas-1.1.2-cp37-cp37m-manylinux1_x86_64.whl (10.5 MB)
|████████████████████████████████| 10.5 MB 4.3 MB/s eta 0:00:01 |█████████ | 3.0 MB 4.3 MB/s eta 0:00:02
Collecting numpy>=1.15.4
Downloading numpy-1.19.2-cp37-cp37m-manylinux2010_x86_64.whl (14.5 MB)
|████████████████████████████████| 14.5 MB 48.5 MB/s eta 0:00:01
Collecting pytz>=2017.2
Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)
|████████████████████████████████| 510 kB 30.0 MB/s eta 0:00:01
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: six>=1.5 in /srv/conda/envs/notebook/lib/python3.7/site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
Installing collected packages: numpy, pytz, pandas
Successfully installed numpy-1.19.2 pandas-1.1.2 pytz-2020.1
import pandas as pd
matches_raw_df = pd.read_csv('matches.csv')
matches_raw_df
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
import jovian
jovian.commit(files = ['matches.csv'])
[jovian] Attempting to save notebook..
[jovian] Please enter your API key ( from https://jovian.ml/ ):
API KEY: ········
[jovian] Updating notebook "srijansrj5901/ipl-data-anaysis-78bb0" on https://jovian.ml/
[jovian] Uploading notebook..
[jovian] Capturing environment..
[jovian] Uploading additional files...
[jovian] Committed successfully! https://jovian.ml/srijansrj5901/ipl-data-anaysis-78bb0
matches_raw_df[(matches_raw_df.toss_winner == matches_raw_df.winner) & (matches_raw_df.toss_decision == 'field')].groupby('season').winner.count() /
season
2008 19
2009 14
2010 10
2011 27
2012 18
2013 15
2014 24
2015 14
2016 32
2017 28
2018 27
2019 31
Name: winner, dtype: int64
matches_raw_df.groupby('season').toss_decision.value_counts()
season toss_decision
2008 field 32
bat 26
2009 bat 35
field 22
2010 bat 39
field 21
2011 field 48
bat 25
2012 bat 37
field 37
2013 bat 45
field 31
2014 field 41
bat 19
2015 field 34
bat 25
2016 field 49
bat 11
2017 field 48
bat 11
2018 field 50
bat 10
2019 field 50
bat 10
Name: toss_decision, dtype: int64
matches_raw_df.winner.value_counts()
Mumbai Indians 109
Chennai Super Kings 100
Kolkata Knight Riders 92
Royal Challengers Bangalore 84
Kings XI Punjab 82
Rajasthan Royals 75
Delhi Daredevils 67
Sunrisers Hyderabad 58
Deccan Chargers 29
Gujarat Lions 13
Pune Warriors 12
Rising Pune Supergiant 10
Delhi Capitals 10
Kochi Tuskers Kerala 6
Rising Pune Supergiants 5
Name: winner, dtype: int64
jovian.commit()
[jovian] Attempting to save notebook..