IPL Auction Analysis
IPL Auction Analysis
Project Report
Session 2024 -2025
Informatics Practices
Class XII
Project Topic: IPL Auction DataAnalysis
Submitted To:
Mr Ashirwad Mahalkari
Submitted By:
Manit Chawla
1|Page
CERTIFICATE
This is to certify that Manit Chawla of class XII has successfully
completed a project titled “IPL Auction Analysis” for the subject
Informatics Practices in the academic year 2024 - 2025. The candidate
has followed all the guidelines given by CBSE to complete the project.
-------------------------------- ---------------------------------
(Mr. Ashirwad Mahalkari)
------------------------------- (External
Examiner)
2|Page
Acknowledgement
3|Page
Index
1. Abstract
2. The CSV File (BACK END)
3. Main Menu and Source code
4. Search Data and Source code
5. Data Analysis and Source code
6. Charts and Source code
7. Sources
4|Page
Abstract
The project is basically reading data from a csv file named ‘auction.csv’
(Data obtained from Kaggle.com) which contains records of 1051
cricket players and their analysis on IPL auctions. It contains
information such as name of the players, country to which the players
belong, the teams they will play for, their base price etc.
It is a menu driven project and I have given options for Showing data,
searching specific data and for Data Visualization where I have
displayed different types of charts such as Bar chart, Multibar chart, Pie
chart and Histogram, using matplotlib library of python.
5|Page
Handling CSV files
csv stands for comma separated values. A csv file is just like a simple
text file except that the data present in it is well formatted in a way that
each data value is separated from the other with a comma. A csv file
normally also has the header row which acts as column headings. csv
files are light weight yet they can store thousands of records without
occupying a lot of memory as compared to other ways of storing data
such as DBMS software.
Header Row
Data / Records
Example:
import pandas
df = pandas.read_csv('c:\\test.csv', header=0,
sep=',') print(df) Output:
6|Page
Rno Name Marks
0 1 Raj 99
1 2 Ajay 25
2 3 Vijay 10
As we can see that the header row has become the column headings
and row indices are kept as default. header=0 means that the header
row is at line 0 in the csv file. sep = ‘,’ means the separator used in
the csv file is comma. Both these parameters are optional.
Example:
import pandas eno = [10, 20, 30] name = ['Tom', 'Scott', 'Nia']
salary = [50000, 80000, 95000] df = pandas.DataFrame()
#Creating an empty dataframe df['Empno'] = eno #Filling
employee numbers in ‘Empno’ column df['Name'] = name
#Filling names in ‘Name’ column df['Salary'] = salary
#Filling salary in ‘Salary’ column df.to_csv('c:\\employee.csv')
#file is created in C: drive
Now when we open the ‘employee.csv’ file from C: drive, it will look
like following:
7|Page
As we can see that the data is exported. But there is one problem.
The index column is also written in the csv file which looks bit odd.
We can solve this problem by using ‘index = False’ parameter inside
the to_csv() function.
df.to_csv('c:\\employee.csv', index=False)
Now the index column will not be written in the csv file. We can also
deny the column header from being written in the csv file by using
‘header = False’ parameter inside the to_csv() function.
8|Page
THE CSV USED IN PROJECT – ‘auction.csv’
(showing first 15 records out of 1051 records)
9|Page
Main Menu
# Search
Menu-------------------------------------------------
---------------------------
def SearchMenu():
while True:
print()
print('----------------------------')
print('Search Data')
print('----------------------------')
print('1. Search Player by Country ')
print('2. Search player by team ')
print('3. Search by Year')
print('4. Search By State')
print('5. Search By player')
print('0. Exit')
print()
10 | P a g e
DataAndSearch.searchbyyear()
elif ch == 4:
DataAndSearch.searchbystate()
elif ch == 5:
DataAndSearch.searchbyplayer()
elif ch == 5:
pass
else:
break
# End Of Search
Menu-------------------------------------------------
---------------------------
# Data Analysis
Menu-------------------------------------------------
---------------------------
def DataAnalysisMenu():
while True:
print()
print('----------------------------')
print('DATA ANALYSIS')
print('----------------------------')
print('1. Show no of players in each team')
print('2. Show no of players from each
country')
print('3. Show no of players for base price')
print('4. Show player names for base price')
print('5. Show player wise base price and
winning bid comparison')
print('0. Exit')
print()
DataAnalysis.showteamwisenumberofplayers()
elif ch == 2:
DataAnalysis.showcountrywisenumberofplayers()
elif ch == 3:
DataAnalysis.showteamwiseBasepricesum()
elif ch == 4:
DataAnalysis.showbasepricewiseplayers()
11 | P a g e
elif ch == 5:
DataAnalysis.showwinningbidandbasepricecomparison()
else:
break
# End Of Data Analysis
Menu-------------------------------------------------
-------------------
# Charts
Menu-------------------------------------------------
---------------------------------
def ChartsMenu():
while True:
print()
print('-----------------')
print('SHOW CHARTS')
print('-----------------')
print('1. Show no of players in each team')
print('2. Show no of players in each
country')
print('3. Show no of players for base price')
print('4. Show base price wise no of
players')
print('5. Show base price V/S winning prize
Comparison')
print('0. Exit')
print()
Charts.showwinningbidandbasepricecomparison()
else:
break
12 | P a g e
# End Of Charts
Menu-------------------------------------------------
---------------------------
while True:
print('---------------------------')
print("IPL AUCTION ANALYSIS PROJECT")
print('--------------------------- ')
print('1. Show All Data')
print('2. Search Data')
print('3. Data Analysis')
print('4. Charts')
print('0. Exit')
print()
ch = int(input('Enter Your Choice: '))
if ch == 1:
DataAndSearch.ShowAllData()
elif ch == 2:
SearchMenu()
elif ch == 3:
DataAnalysisMenu()
elif ch == 4:
ChartsMenu()
else:
break
13 | P a g e
Search Player By Country:
14 | P a g e
Search By Year:
15 | P a g e
Search By State:
16 | P a g e
Search By Player:
import pandas
import matplotlib.pyplot as plt
import numpy as np
pandas.set_option('display.max_rows', 50000)
pandas.set_option('display.max_columns', 25)
pandas.set_option('display.max_colwidth', 30)
pandas.set_option("display.width", 2000)
17 | P a g e
df = pandas.read_csv('auction.csv')
def ShowAllData():
print(df[['Country','Player','Team','Base
price','Winning bid','Year']])
print(df.to_string(index=False))
print(df.head(15))
input('Press Enter To Continue......')
return()
# Search
Functions--------------------------------------------
-------------------------------------------------
def searchbycountry():
tempdf =
pandas.DataFrame(columns=['Country','Player','Team','
Base price','Winning bid','Year'])
b = input("Enter Name of the country: ")
for i in df.index:
if b.lower() in df.at[i, 'Country'].lower():
tempdf.loc[i] = df.loc[i]
print(tempdf.to_string(index=False))
print()
input('press enter to continue......')
return()
def searchbyteam():
tempdf =
pandas.DataFrame(columns=['Country','Player','Team','
Base price','Winning bid','Year'])
b = input("Enter Name of the team: ")
for i in df.index:
if b.lower() in df.at[i, 'Team'].lower():
tempdf.loc[i] = df.loc[i]
print(tempdf.to_string(index=False))
print()
input('press enter to continue......')
return()
def searchbyyear():
tempdf =
pandas.DataFrame(columns=['Country','Player','Team','
Base price','Winning bid','Year'])
b = int(input("Enter Year: "))
18 | P a g e
for i in df.index:
if b==df.at[i, 'Year']:
tempdf.loc[i] = df.loc[i]
print(tempdf.to_string(index=False))
print()
input('press enter to continue......')
return()
def searchbystate():
tempdf =
pandas.DataFrame(columns=['Country','Player','Team','
Base price','Winning bid','Year'])
b = input("Enter the state: ")
for i in df.index:
if b.lower() in df.at[i, 'Team'].lower():
tempdf.loc[i] = df.loc[i]
print(tempdf.to_string(index=False))
print()
input('press enter to continue......')
return()
def searchbyplayer():
tempdf =
pandas.DataFrame(columns=['Country','Player','Team','
Base price','Winning bid','Year'])
b = input("Enter the player: ")
for i in df.index:
if b.lower() in df.at[i, 'Player'].lower():
tempdf.loc[i] = df.loc[i]
print(tempdf.to_string(index=False))
print()
input('press enter to continue......')
return()
# End Of Search
Functions--------------------------------------------
-------------------------------------------------
19 | P a g e
Data Analysis (Sub Menu)
20 | P a g e
21 | P a g e
Show No. Of Players From Each Country:
22 | P a g e
Show No.Of Players For Base Price:
23 | P a g e
Show Player Names For Base Price:
24 | P a g e
Show Player Wise Base Price And Winning Bid
Comparison:
25 | P a g e
Source Code (DataAnalysis.py)
import pandas
import matplotlib.pyplot as plt
import numpy as np
pandas.set_option('display.max_rows', 50000)
pandas.set_option('display.max_columns', 25)
pandas.set_option('display.max_colwidth', 30)
pandas.set_option("display.width", 2000)
df = pandas.read_csv('auction.csv')
# Data Analysis
Functions--------------------------------------------
-------------------------------------------------
def showteamwisenumberofplayers():
s=df['Team'].value_counts()
tempdf = pandas.DataFrame(columns=['Team','No. of
Players'])
tempdf['Team'] = s.index
tempdf['No. of Players'] = s.values
print(tempdf.to_string(index=False))
print()
input('press enter to continue....')
return()
def showcountrywisenumberofplayers():
s=df['Country'].value_counts()
tempdf = pandas.DataFrame(columns=['Country','No.
of Players'])
tempdf['Country'] = s.index
tempdf['No. of Players'] = s.values
26 | P a g e
print(tempdf.to_string(index=False))
print()
input('press enter to continue....')
return()
def showteamwiseBasepricesum():
df1 = df.groupby('Team')['Base price'].agg('sum')
df1 = df1.reset_index()
df1.columns = ['Team', 'Total Base Price']
print(df1.to_string(index=False))
print()
input('press enter to continue....')
return()
def showbasepricewiseplayers():
# Create a new DataFrame with 'Base price' and
'Player'
tempdf = df[['Base price', 'Player']]
def showwinningbidandbasepricecomparison():
# Create a new DataFrame with ,'Player',Base
price', 'Winning bid'
tempdf = df[['Player', 'Base price', 'Winning
bid']]
tempdf = tempdf.head(10)
28 | P a g e
Show No. Of Players In Each Team:
29 | P a g e
Show Country Wise Number Of Players:
30 | P a g e
Show No. Of Players For Base Price:
31 | P a g e
Show Base Price Wise No. Of Price:
32 | P a g e
Show Base Price V/S Winning Bid Comparison:
pandas.set_option('display.max_rows', 50000)
pandas.set_option('display.max_columns', 25)
pandas.set_option('display.max_colwidth', 30)
pandas.set_option("display.width", 2000)
df = pandas.read_csv('auction.csv')
# Chart
Functions--------------------------------------------
-------------------------------------------------
def Showteamwisenumberofplayers():
def addlabels(x, y):
for i in range(len(x)):
plt.text(i, y[i], y[i], ha='center')
s = df['Team'].value_counts()
s1 = s.head(15)
x = s1.index
y = s1.values
plt.bar(x, y, color='#D4D4FF')
plt.xlabel("----------------Team--------------->
")
plt.ylabel("------------No of
Players------------->")
addlabels(x, y)
plt.xticks(rotation=90)
plt.tight_layout()
plt.title('TEAM WISE ANALYSIS')
plt.show()
return ()
def Showcountrywisenumberofplayers():
s = df['Country'].value_counts()
x = []
y = []
colors = ['#ff9999', '#66b3ff', '#99ff99',
34 | P a g e
'#ffcc99', '#c2c2f0', '#ffb3e6','k']
for i in s.index:
if s[i] > 16:
x.append(s[i])
y.append(i)
Showcountrywisenumberofplayers()
def showteamwisebasepricesum():
def addlabels(x, y):
for i in range(len(x)):
plt.text(i, y[i], y[i], ha='center')
35 | P a g e
def showbasepricewiseplayers():
s = df['Base price']
l = s.values
print(l)
plt.hist(l, bins=[0, 20, 40, 60, 80, 100, 200],
edgecolor='k', facecolor='#FFD699')
plt.xticks([0, 20, 40, 60, 80, 100, 200])
plt.xlabel("------------------------------------
>Base Price")
plt.ylabel("------------------------->Number of
players")
plt.title('BASE PRICE ANALYSIS')
plt.tight_layout()
plt.show()
return ()
def showwinningbidandbasepricecomparison():
tempdf = pandas.DataFrame(columns=['Country',
'Player', 'Team', 'Base price', 'Winning bid',
'Year'])
for i in tempdf.index:
tempdf.at[i, 'Winning bid'] =
float(tempdf.at[i, 'Winning bid'])
# End Of Chart
Functions--------------------------------------------
-------------------------------------------------
36 | P a g e
Removal Of Extra Spaces
from the CSV:
import pandas
import matplotlib.pyplot as plt
import numpy as np
pandas.set_option('display.max_rows', 50000)
pandas.set_option('display.max_columns', 25)
pandas.set_option('display.max_colwidth', 30)
pandas.set_option("display.width", 2000)
df = pandas.read_csv('auction.csv')
for i in df.index:
df.at[i,'Country'] = df.at[i,'Country'].strip()
s = df['Country'].value_counts()
print(s)
37 | P a g e
Sources:
38 | P a g e
39 | P a g e