You are on page 1of 45

Informatics Practices Project File

2021-22

IPL 2021 Top 25 Bowlers

Done by: - Mayan Ali, Alaik Asif, Abdur Rafay Taha


Class: - 12 Com H
Board Exam Roll No. 27613348
Name of Teacher: - Mr. Sajit Nair
Period of Study: - 2021-2022
1|Page
THE INDIAN HIGH SCHOOL, DUBAI
BONAFIDE CERTIFICATE

This is to certify that Master Mayan Ali of class 12 Com H has

completed his Project on IPL 2021 Top 25 Bowlers under my

supervision. He has taken proper care and shown utmost

sincerity in completing it.

Teacher in Charge: - Mr. K. Sajit Nair


Signature of Internal Examiner: -
Signature of External Examiner: -
2|Page
ACKNOWLEDGEMENT

I would like to convey my heartfelt thanks to K. Sajit Nair,


my Informatics Teacher, who always gave me valuable
suggestions and guided me in the completion of this
project. He helped me to understand & remember the
important details of the project that I would have
otherwise lost. My project file has been a success only
because of his guidance. I would like to further convey my
thanks to my friends and family who have helped me in
minute areas of this file.

Name: - Mayan Ali


Board Exam Roll No: - 27613348

3|Page
INDEX
S.no Topic Page No.

1. Introduction 5

2. Objective of Project 6

3. Project Data(CSV) 7

4. Program Code 8

5. Sample Output 33

6. Conclusion 44

7. Bibliography 45

4|Page
Introduction

The Indian Premier league is a professional 20 over cricket League


in India. It is usually contested between March and May every year
by usually eight teams. However, due to the covid-19 outbreak
within the team bubbles in May 2021, the 2021 season was
suspended indefinitely. On 29 May 2021, the BCCI announced that
the remaining matches of the tournament would be played in
the United Arab Emirates in September and October 2021.The
League was founded in the year 2008 by the BCCI (Board of Control
for Cricket in India).
The data to be collected for this program is ‘Top 25 Bowlers’.
The program will offer tabular and graphical presentation of data
based on players stats. The program will be designed in a manner
allowing manipulation of data such as updating the table, adding
new data etc.
It will be a menu driven program providing users easier access to
different aspects of the program.
I chose this project as sports is a widespread interest and as IPL is
the major event going on in cricket, I decided to go with this topic as
it would be of interest to many users.
The project will be using Python 3.9.0 as front-end and Microsoft
Excel CSV file as back-end.

5|Page
Objective of Project

1. To create a program showing bowlers’ stats.


2. Enabling easy access to data.
3. To enable manipulation of data based on latest figures.
4. To broaden my knowledge on Python.

6|Page
Project Data (CSV)

7|Page
Program Code
from clrprint import*
import pandas as pd
import matplotlib.pyplot as pl
import numpy as np
pd.options.display.max_columns=20
df=pd.read_csv("C://Users//mayan//OneDrive//Desktop//TEST.cs")
df.index=range(1,26)
import csv
import sys
def main():
menu()
def menu():
clrprint("****************WELCOME TO THE OFFICIAL IPL TOP
25 BALLERS LIST.******************")
print()
choice = input("""
Player Record
A: To see records of specific player in table format
B: To see records of specific player in graphical format

8|Page
Team Record
C: To see player rankings in table format
D: To see records coloum wise and team wise

Alter Table
E: To update the Top 25 bowlers list
F: To delete a row or column

G: To Exit

Please enter your choice: """)


if choice=="A" or choice=="a": #To see records of specific player
in table format
nam=int(input("Enter 1 for names of all players\nEnter 2 if you
already know the player you wish to search for\nENTER: "))
print()
if nam==1:
clrprint('HERE ARE THE LIST OF PLAYERS')
clrprint()
clrprint(df['PLAYER'],clr='g')

9|Page
print()
plynam=input("As this programme is very case sensitive, you
are required to type in the PLAYERs name using the correct
letter case(upper or lower case): ")
print()
x=df['PLAYER']==plynam
clrprint('THIS IS '+plynam+' DATA')
clrprint(df[x],clr='y')
if nam==2:
plynam=input("As this programme is very case sensitive, you
are required to type in the players name using the
correct letter case(upper or lower case): ")
print()
x=df['PLAYER']==plynam
print('THIS IS '+plynam+' DATA')
clrprint(df[x],clr='y')
menu()
elif choice=="B" or choice=="b":#graphic data
vis=int(input("1 for Bar Graph\n2 for Line Graph\n3 for
Histogram\n4 to EXIT\nENTER: "))

10 | P a g e
print()
if vis==1:#bar
col=input('a.Matches\nb.Runs\nc.Overs\nd.Wicket
\ne.Economy\nf.4W\ng.5W\nEnter any of the column
name mentioned aboved:')
col=col.upper()
print()
num=int(input('Enter the number of players results you wish
to compare: '))
print()
a=1
x=[]
while a<=num:
pos=int(input('Enter the position of the player you wish to
compare: '))
a=a+1
pos=pos-1
x.append(pos)
y=df.iloc[x]
if col=='MATCHES':

11 | P a g e
pl.title('TOTAL NO OF '+col+'\nPLAYED BY THE FOLLOWING
PLAYERS',color='red')
if col=='RUNS':
pl.title('TOTAL '+col+' CONCEDED BY THE FOLLOWING
PLAYERS',color='red')
if col=='WICKET':
pl.title('TOTAL NUMBER OF \nWICKETS BY THE FOLLOWING
PLAYERS',color='red')
if col=='ECONOMY':
pl.title('TOTAL AVERAGE ECONOMY \nBY THE FOLLOWING
PLAYERS',color='red')
if col=="OVERS":
pl.title('TOTAL NO OF OVERS \nPLAYED BY THE FOLLOWING
PLAYERS',color='red')
if col=='4W' or col=='5W':
pl.title('TOTAL NUMBER OF \n'+col+' HAUL IN A MATCH BY
THE FOLLOWING PLAYERS',color='red')
pl.ylabel('NO OF '+col,color='yellow')
pl.xlabel('PLAYER NAMES',color='yellow')
pl.bar(y['PLAYER'],y[col])

12 | P a g e
pl.show()
if vis==2: #linegraph
col=input('a.Matches\nb.Runs\nc.Overs\nd.Wicket
\ne.Economy\nf.4W\ng.5W\nEnter any of the column
name mentioned aboved:')
col=col.upper()
print()
num=int(input('Enter the number of players results you wish
to compare: '))
print()
a=1
x=[]
while a<=num:
pos=int(input('Enter the position of the player you wish
to compare: '))
a=a+1
pos=pos-1
x.append(pos)
y=df.iloc[x]
if col=='MATCHES':

13 | P a g e
pl.title('TOTAL NO OF '+col+'\nPLAYED BY THE FOLLOWING
PLAYERS',color='red')
if col=='RUNS':
pl.title('TOTAL '+col+' CONCEDED BY THE FOLLOWING
PLAYERS',color='red')
if col=='WICKET':
pl.title('TOTAL NUMBER OF \nWICKETS BY THE FOLLOWING
PLAYERS',color='red')
if col=='ECONOMY':
pl.title('TOTAL AVERAGE ECONOMY \nBY THE FOLLOWING
PLAYERS',color='red')
if col=="OVERS":
pl.title('TOTAL NO OF OVERS \nPLAYED BY THE FOLLOWING
PLAYERS',color='red')
if col=='4W' or col=='5W':
pl.title('TOTAL NUMBER OF \n'+col+' HAUL IN A MATCH BY
THE FOLLOWING PLAYERS',color='red')
pl.ylabel('NO OF '+col,color='yellow')
pl.xlabel('PLAYER NAMES',color='yellow')
pl.plot(y['PLAYER'],y[col])

14 | P a g e
pl.show()
if vis==3:
col=input('a.Matches\nb.Runs\nc.Overs
\nd.Wicket\ne.Economy\nf.4W\ng.5W\nEnter any of the
column name mentioned aboved:')
col=col.upper()
print()
if col=='MATCHES':
pl.title('HISTOGRAM OF NUMBER OF MATCHES
PLAYED',color='red')
pl.ylabel('NO OF PLAYERS',color='yellow')
pl.xlabel('MATCHES PLAYED',color='yellow')
pl.hist(df[col])
pl.show()
if col=='RUNS':
pl.title('HISTOGRAM OF RUNS CONCEDED',color='red')
pl.ylabel('NO OF PLAYERS',color='yellow')
pl.xlabel('RUNS CONCEDED',color='yellow')
pl.hist(df[col])
pl.show()

15 | P a g e
if col=='WICKET':
pl.title('HISTOGRAM OF HIGHEST WICKETS
TAKEN',color='red')
pl.ylabel('NO OF PLAYERS',color='yellow')
pl.xlabel('WICKETS TAKEN',color='yellow')
pl.hist(df[col])
pl.show()
if col=='ECONOMY':
pl.title('HISTOGRAM OF AVERAGE ECONOMY
RATE',color='red')
pl.ylabel('NO OF PLAYERS',color='yellow')
pl.xlabel('AVERAGE ECONOMY',color='yellow')
pl.hist(df[col])
pl.show()
if col=="OVERS":
pl.title('HISTOGRAM OF NUMBER OF OVERS',color='red')
pl.ylabel('NO OF PLAYERS',color='yellow')
pl.xlabel('NO OF OVERS PLAYED',color='yellow')
pl.hist(df[col])
pl.show()

16 | P a g e
if col=='4W':
pl.title('HISTOGRAM OF NUMBER OF 4 WICKET
HAULS',color='red')
pl.ylabel('NO OF PLAYERS',color='yellow')
pl.xlabel('NO OF FOUR WICKETS IN A MATCH',color='yellow')
pl.hist(df[col])
pl.show()
if col=='5W':
pl.title('HISTOGRAM OF NUMBER OF 5 WICKET
HAULS',color='red')
pl.ylabel('NO OF PLAYERS',color='yellow')
pl.xlabel('NO OF FIVE WICKETS IN A MATCH',color='yellow')
pl.hist(df[col])
pl.show()
menu()
elif choice == "C" or choice =="c":
rank=int(input("Enter no. of rows you want to see or enter '25'
to see entire table:"))
print()
clrprint('Here is the team based stats of the Top',rank,'Ballers

17 | P a g e
in IPL history:')
print()
clrprint(df.head(rank),clr='g')
menu()
elif choice == "D" or choice =="d":
col=input('a.Matches\nb.Runs\nc.Overs\nd.Wicket
\ne.Economy\nf.4W\ng.5W\nh.Team\nEnter any of the
column name mentioned aboved:')
col=col.upper()
print()
if col=='MATCHES':
order=df.loc[:,['PLAYER','MATCHES','TEAM']]
asc_desc=int(input('Enter 1 to see the total matches played
by players from HIGHEST to LOWEST\nEnter 2 to
see the total matches played by players from
LOWEST to HIGHEST\nENTER:'))
print()
count=df['PLAYER'].count()
rank=[]
pos=1

18 | P a g e
while pos<=count:
rank.append(pos)
pos=pos+1
order=order.sort_values(by=['MATCHES'],
ascending=False,ignore_index=True)
if asc_desc==1:
clrprint('NUMBER OF MATCHES PLAYED:')
print()
clrprint(order,clr='y')
if asc_desc==2:
clrprint('NUMBER OF MATCHES PLAYED:')
print()
order=order.sort_values(by=['MATCHES'])
clrprint(order,clr='y')
if col=='OVERS':
order=df.loc[:,['PLAYER','OVERS','TEAM']]
asc_desc=int(input('Enter 1 to see the overs played by
players from HIGHEST to LOWEST\nEnter 2 to see
the total runs scored by players from LOWEST to
HIGHEST\nENTER: '))

19 | P a g e
print()
count=df['PLAYER'].count()
rank=[]
pos=1
while pos<=count:
rank.append(pos)
pos=pos+1
order=order.sort_values(by=['OVERS'],
ascending=False,ignore_index=True)
if asc_desc==1:
clrprint('NUMBER OF OVERS PLAYED:')
print()
clrprint(order,clr='y')
if asc_desc==2:
clrprint('NUMBER OF OVERS PLAYED:')
print()
order=order.sort_values(by=['OVERS'])
clrprint(order,clr='y')
if col=='RUNS':
order=df.loc[:,['PLAYER','RUNS','TEAM']]

20 | P a g e
asc_desc=int(input('Enter 1 to see the total runs scored by
players from HIGHEST to LOWEST\nEnter 2 to see
the total runs scored by players from LOWEST to
HIGHEST\nENTER: '))
print()
count=df['PLAYER'].count()
rank=[]
pos=1
while pos<=count:
rank.append(pos)
pos=pos+1
order=order.sort_values(by=['RUNS'],
ascending=False,ignore_index=True)
if asc_desc==1:
clrprint('NUMBER OF RUNS CONCEDED')
print()
clrprint(order,clr='y')
if asc_desc==2:
clrprint('NUMBER OF RUNS CONCEDED')
clrprint()

21 | P a g e
order=order.sort_values(by=['RUNS'])
clrprint(order,clr='y')
if col=='WICKET':
order=df.loc[:,['PLAYER','WICKET','TEAM']]
asc_desc=int(input('Enter 1 to see the wickets taken by
players from HIGHEST to LOWEST\nEnter 2 to see
the wickets taken by players from LOWEST to
HIGHEST\nENTER: '))
print()
count=df['PLAYER'].count()
rank=[]
pos=1
while pos<=count:
rank.append(pos)
pos=pos+1
order=order.sort_values(by=['WICKET'],
ascending=False,ignore_index=True)
if asc_desc==1:
clrprint('TOTAL WICKETS TAKEN BY THE PLAYERS')
print()

22 | P a g e
clrprint(order,clr='y')
if asc_desc==2:
clrprint('TOTAL WICKETS TAKEN BY THE PLAYERS')
print()
order=order.sort_values(by=['WICKET'])
clrprint(order,clr='y')
if col=='ECONOMY':
order=df.loc[:,['PLAYER','ECONOMY','TEAM']]
asc_desc=int(input('Enter 1 to see the average economy rate
of players from HIGHEST to LOWEST\nEnter 2 to
see the average economy rate of players from
LOWEST to HIGHEST\nENTER: '))
print()
count=df['PLAYER'].count()
rank=[]
pos=1
while pos<=count:
rank.append(pos)
pos=pos+1
order=order.sort_values(by=['ECONOMY'],

23 | P a g e
ascending=False,ignore_index=True)
if asc_desc==1:
clrprint('AVERAGE ECONOMY RATE OF THE PLAYERS')
print()
clrprint(order,clr='y')
if asc_desc==2:
clrprint('AVERAGE ECONOMY RATE OF THE PLAYERS')
print()
order=order.sort_values(by=['ECONOMY'])
clrprint(order,clr='y')
if col=='4W':
order=df.loc[:,['PLAYER','4W','TEAM']]
asc_desc=int(input('Enter 1 to see the total number of 4
Wicket Hauls made by players from HIGHEST to
LOWEST\nEnter 2 to see the total number of 4
Wicket Hauls made by players from LOWEST to
HIGHEST\nENTER: '))
print()
count=df['PLAYER'].count()
rank=[]

24 | P a g e
pos=1
while pos<=count:
rank.append(pos)
pos=pos+1
order=order.sort_values(by=['4W'],
ascending=False,ignore_index=True)
if asc_desc==1:
clrprint('NUMBER OF 4 WICKET HAULS MADE BY THE
PLAYERS')
print()
clrprint(order,clr='y')
if asc_desc==2:
clrprint('NUMBER OF 4 WICKET HAULS MADE BY THE
PLAYERS')
print()
order=order.sort_values(by=['4W'])
clrprint(order,clr='y')
if col=='5W':
order=df.loc[:,['PLAYER','5W','TEAM']]
asc_desc=int(input('Enter 1 to see the total number of 5

25 | P a g e
Wicket Hauls made by players from HIGHEST to
LOWEST\nEnter 2 to see the total number of 5
Wicket Hauls made by players from LOWEST to
HIGHEST\nENTER: '))
print()
count=df['PLAYER'].count()
rank=[]
pos=1
while pos<=count:
rank.append(pos)
pos=pos+1
order=order.sort_values(by=['5W'],
ascending=False,ignore_index=True)
if asc_desc==1:
clrprint('NUMBER OF 5 WICKET HAULS MADE BY THE
PLAYERS')
print()
clrprint(order,clr='y')
if asc_desc==2:
clrprint('NUMBER OF 5 WICKET HAULS MADE BY THE

26 | P a g e
PLAYERS')
print()
order=order.sort_values(by=['5W'])
clrprint(order,clr='y')
if col=='TEAM':
tm=input('a.RCB\nb.CSK\nc.RR\nd.KXIP\ne.KKR\n
f.MI\ng.SRH\nh.DC\nENTER:')
tm=tm.upper()
print()
clrprint('Here are the '+tm+' players from the Top 25
Bowlers')
w=df['TEAM']==tm
gro=df[w]
clrprint(gro,clr='y')
menu()
elif choice == "E" or choice =="e":
ind=int(input("Enter player position:"))
nam=input("Name of the new player:")
mat=int(input("Matches played:"))
run=int(input("Runs Conceded:"))

27 | P a g e
overs=float(input("Overs played:"))
wickets=int(input("Wickets taken:"))
economy=float(input("Economy:"))
four=int(input("4 wickets taken:"))
five=int(input("5 wickets taken:"))
team=input("Team:")
print()
confirm=input('Are you sure that you want to update the
table?: ')
confirm=confirm.upper()
for i in confirm:
if confirm=='YES':
print()
clrprint('Here is the details of the new player added in the
list:')
print()
newrow=pd.DataFrame([ind,nam,mat,run,overs,wickets,
economy,four,five,team],index=['POSITION','PLAYER',
'MATCHES','RUNS','OVERS','WICKET','ECONOMY','4W',
'5W','TEAM'],columns=['New Data'])

28 | P a g e
clrprint(newrow,clr='y')
print()
clrprint('Here is the updated list of the Top 25 bowlers:')
print()
df.loc[ind]=[nam,mat,run,overs,wickets,economy,four,
five,team]
clrprint(df,clr='g')
if confirm=='NO':
cho=int(input('Enter 1 to add correct data\nEnter 2 to not
add any data\nEnter choice: '))
print()
if cho==1:
ind=int(input("Enter player position:"))
nam=input("Name of the new player:")
mat=int(input("Matches played:"))
run=int(input("Runs Conceded:"))
overs=float(input("Overs played:"))
wickets=int(input("Wickets taken:"))
economy=float(input("Economy:"))
four=int(input("4 wickets taken:"))

29 | P a g e
five=int(input("5 wickets taken:"))
team=input("Team:")
print()
clrprint('Here is the details of the new player added in
the list:')
print()
newrow=pd.DataFrame([ind,nam,mat,run,overs,
wickets,economy,four,five,team],index=['POSITION',
'PLAYER','MATCHES','RUNS','OVERS','WICKET',
'ECONOMY''4W','5W','TEAM'],columns=['New Data'])
clrprint(newrow,clr='y')
print()
clrprint('Here is the updated list of the Top 25 bowlers:')
print()
df.loc[ind]=[nam,mat,run,overs,wickets,economy,
four,five,team]
clrprint(df,clr='g')
if cho==2:
clrprint('No data has been modified as per your
choice!',clr='r')

30 | P a g e
print()
break
menu()
elif choice == "F" or choice =="f":
clrprint(df['PLAYER'],clr='g')
print()
cho=int(input('How many records do you wish to delete?: '))
print()
for i in range(cho):
d=int(input('Position of Player to delete:'))
print()
newdf=df.drop([d])
clrprint(newdf,clr='y')
print()
menu()
elif choice=="G" or choice=="g":
clrprint('************THANK YOU FOR USING OUR IPL TOP
25 BOWLERS LIST************')
sys.exit
else:

31 | P a g e
clrprint("ERROR INVALID CHOICE ",clr='r')
clrprint("PLEASE TRY AGAIN",clr='r')
menu()
main()
Functions/Modules used: -
1. main() – Displays menu of the program.
2. menu() – Entire list of choices of program. It is displayed after
running every choice.
3. sys – Used for exiting the program.
4. clrprint - Used for changing the color of output.
5. pandas – Used to display the dataframe of Players
6. matplolib – Used to display graphs and charts.
7. csv – To be able to make changes to the csv, it is required to
import csv.

32 | P a g e
Sample Output
Sample 1

Sample 2

33 | P a g e
Sample 3.1

34 | P a g e
Sample 3.2

35 | P a g e
Sample 3.3

36 | P a g e
Sample 4.1

37 | P a g e
Sample 4.2

Sample 5.1

38 | P a g e
Sample 5.2

39 | P a g e
Sample 6.1

40 | P a g e
Sample 6.2

Sample 7

41 | P a g e
42 | P a g e
Sample 8

43 | P a g e
Sample 9

Conclusion
"Python is a high-level, general-purpose programming
language that is interpreted."
This project's coding needed a lot of higher-order thinking
abilities and interaction with the software, which helped me
develop patience and determination to finish this pretty
enjoyable project.
In trying to come up with solutions to given queries and
difficulties, my ability to think outside the box has risen
enormously.

44 | P a g e
This assignment allowed me to broaden my python
knowledge. It has aided me in considering other approaches
to write code to get the desired result.
Overall, this project taught me about Python's capability and
ability to address modern-day difficulties.
Bibliography
https://pypi.org/
https://www.iplt20.com/stats/2021/mostWkts?stats_type=
bowling
https://stackoverflow.com/
https://ncert.nic.in/textbook.php

45 | P a g e

You might also like