0% found this document useful (0 votes)
8 views39 pages

IPL Auction Analysis

Uploaded by

chawlamanit14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views39 pages

IPL Auction Analysis

Uploaded by

chawlamanit14
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 39

The Emerald Heights International School

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.

Project In charge School seal

-------------------------------- ---------------------------------
(Mr. Ashirwad Mahalkari)

------------------------------- (External
Examiner)

2|Page
Acknowledgement

A project is never a unilateral effort; there is always a team of other


person who contributes in one or more ways. The credit for the
successful completion of this project goes to number of people without
whose help I would not have been able to do justice to this project.
Therefore, I would like to take this opportunity to express my gratitude
towards them.

I would like to express my indebtedness towards our respected


President sir for his inspiring thought and explanation. It is indeed a
great pride for me to acknowledge a deep gratitude for the valuable
and magnanimous guidance and generous assistance extended to me
by our teacher Ashirwad Sir whose vigilant supervision helped me to
shape my work.

I am equally thankful to my parents, all my friends and well-wishers who


extended all possible support and help at different stages of this project
and encouraged me throughout this project.

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.

In this project, I have used Python as a programming language,


PyCharm as IDLE, and a CSV file for data analysis.

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.

A typical csv file might look like following:

Header Row
Data / Records

Python has functions that allow us to work with csv files.

1. Importing csv data in a dataframe:


To import data from a csv file we need to use the function read_csv()
with pandas module. The read_csv() function reads all data from a
csv file and puts it in a dataframe. The header row / First row in the
csv file is automatically treated as column labels in the DataFrame.
The indices will be the default numeric indices.

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.

Exporting data in csv file from dataframe:


To export data which is present in a dataframe we need to use the
function to_csv() with the DataFrame object.

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.

df.to_csv('c:\\employee.csv', index=False, header = False)

8|Page
THE CSV USED IN PROJECT – ‘auction.csv’
(showing first 15 records out of 1051 records)

9|Page
Main Menu

Source code (MainMenu.py):


import DataAndSearch
import DataAnalysis
import Charts

# 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()

ch = int(input('Enter Your Choice: '))


if ch == 1:
DataAndSearch.searchbycountry()
elif ch == 2:
DataAndSearch.searchbyteam()
elif ch == 3:

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()

ch = int(input('Enter Your Choice: '))


if ch == 1:

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()

ch = int(input('Enter Your Choice: '))


if ch == 1:
Charts.Showteamwisenumberofplayers()
elif ch == 2:
Charts.Showcountrywisenumberofplayers()
elif ch == 3:
Charts.showteamwisebasepricesum()
elif ch == 4:
Charts.showbasepricewiseplayers()
elif ch == 5:

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

Search Data (Sub Menu)

13 | P a g e
Search Player By Country:

Search Player By Team :

14 | P a g e
Search By Year:

15 | P a g e
Search By State:

16 | P a g e
Search By Player:

Source Code (DataAndSearch.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)

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)

Show No.Of Players In Each Team:

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']]

# Print the DataFrame with Base price and Player


columns
print(tempdf.to_string(index=False))

# Wait for user input to continue


print()
input('Press enter to continue....')
return

def showwinningbidandbasepricecomparison():
# Create a new DataFrame with ,'Player',Base
price', 'Winning bid'
tempdf = df[['Player', 'Base price', 'Winning
bid']]

tempdf = tempdf.sort_values('Winning bid',


ascending=False)

tempdf = tempdf.head(10)

# Print the DataFrame with Base price and Winning


bid columns
print(tempdf.to_string(index=False))
27 | P a g e
# Wait for user input to continue
print()
input('Press enter to continue....')
return

# End Of Data Analysis


Functions--------------------------------------------
------------------------------------------

Charts (Sub Menu)

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:

Source Code (Charts.py):


33 | P a g e
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')

# 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)

# Plot the pie chart


plt.pie(x,colors=colors, autopct='%1.1f%%')
plt.title('COUNTRY WISE NUMBER OF PLAYERS')
plt.tight_layout()
plt.savefig('CHART2.jpg')
plt.xticks(rotation=90)
plt.legend(y, bbox_to_anchor=[0.5, 0.4, 0.6,
0.6], loc = 'upper right')
plt.show()
return ()

Showcountrywisenumberofplayers()

def showteamwisebasepricesum():
def addlabels(x, y):
for i in range(len(x)):
plt.text(i, y[i], y[i], ha='center')

df1 = df.groupby('Team')['Base price'].agg('sum')


df1 = df1.reset_index()
df1.columns = ['Team', 'Total Base Price']
print()
m = df1['Team']
l = df1['Total Base Price']
plt.bar(m, l, color='#00FFFF')
plt.xlabel("------------------------->Team")
plt.ylabel("------------------------->Base price
sum")
addlabels(m, l)
plt.title('TEAM WISE ANALYSIS')
plt.xticks(rotation=90)
plt.tight_layout()
plt.show()
return ()

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'])

tempdf = df.sort_values('Winning bid',


ascending=False)
tempdf = tempdf.head(10)

for i in tempdf.index:
tempdf.at[i, 'Winning bid'] =
float(tempdf.at[i, 'Winning bid'])

tempdf.plot(kind='bar', x='Player', y=['Base


price', 'Winning bid'])
plt.xticks(rotation=90) # Rotate player names
for better visibility
plt.title('Base Price V/S Winning Bid
COMPARISON')
plt.tight_layout()
plt.show()

# 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:

1)www.kaggle.com (Provider of the csv file)


2)matplotlib.org
3)stackoverflow.com
4)chatgpt.com
5)Subject notes provided by the school faculty.

38 | P a g e
39 | P a g e

You might also like