Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment4 #86

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@

# coding: utf-8

# In[1]:


import pandas as pd
import numpy as np


# In[2]:


player_match=pd.read_csv("/home/prateek/Documents/Python/Data_science/Data_science_smp/Ipl/DIM_PLAYER_MATCH.csv",encoding="ISO-8859-1",skiprows=[1])


# In[3]:


player_match


# In[4]:


#Q1:
for i in range(2008,2018):
yp=player_match.loc[(player_match.Age_As_on_match<25) & (player_match.Season_year==i)]
lyp=len(yp)
l=len(player_match)
per=(lyp/l)*100
team=yp.Player_team.value_counts().index[0]
print("% of young players and team having max players in {:d} season={:f} and {}".format(i,per,team))
yp=player_match.loc[(player_match.Age_As_on_match<25) & (player_match.is_manofThematch==1.0)]
lyp=len(yp)
l=len(player_match)
per=(lyp/l)*100
print("Percentage of man of the match award won by young player={}".format(per))


# In[11]:


#Q2:
def bowl(s):
if(s=="Legbreak" or s=="Legbreak googly"):
s="right-handed leg spin bowler"
return s
player_match.Bowling_skill=player_match.Bowling_skill.map(bowl,na_action="ignore")

def null(srs):
if(pd.isnull(srs.Bowling_skill)==True):
srs.Bowling_skill=srs.Batting_hand
return srs
player_match=player_match.apply(null,axis="columns")
right=len(player_match.loc[player_match.Bowling_skill.str.contains("right",case=False) & player_match.is_manofThematch==1])
left=len(player_match.loc[player_match.Bowling_skill.str.contains("left",case=False) & player_match.is_manofThematch==1])
print("Number of times man of the match recieved by right handed player={} , and left handed player={}".format(right,left))


# In[8]:


#Q3:
right_list=list((player_match.loc[player_match.Batting_hand.str.contains("right",case=False) & player_match.is_manofThematch==1]).Player_Name.value_counts().index[0:2])

left_list=list((player_match.loc[player_match.Batting_hand.str.contains("left",case=False) & player_match.is_manofThematch==1]).Player_Name.value_counts().index[0:2])

keeper=((player_match.loc[((player_match.Role_Desc=="Keeper") | (player_match.Role_Desc=="CaptainKeeper")) & player_match.is_manofThematch==1]).Player_Name.value_counts().index[0])


pacers=list(player_match.loc[((player_match.Bowling_skill.str.contains("fast")) | (player_match.Bowling_skill.str.contains("medium"))) & player_match.is_manofThematch==1].Player_Name.value_counts().index[10:13])

A_rounder=(player_match.loc[((player_match.Bowling_skill.str.contains("fast")) | (player_match.Bowling_skill.str.contains("medium"))) & player_match.is_manofThematch==1].Player_Name.value_counts().index[8])

spin=list(player_match.loc[((player_match.Bowling_skill.str.contains("break")) | (player_match.Bowling_skill.str.contains("slow")) | (player_match.Bowling_skill.str.contains("spin")) ) & player_match.is_manofThematch==1].Player_Name.value_counts().index[[7,12]])
#player_match.Bowling_skill.unique()

type(right_list)
team=right_list+left_list+pacers+spin
#right_list.append(keeper)
team.append(keeper)
team.append(A_rounder)
print("best team is:",team)


# In[10]:


#Q4:
match=pd.read_excel("/home/prateek/Documents/Python/Data_science/Data_science_smp/Ipl/DIM_MATCH.xlsx",encoding="ISO-8859-1")
match.dropna(axis="index",subset=["match_winner"],inplace=True)
match

def win_lose(d):
if(d.match_winner!=d.Team1):
d.match_winner=d.match_winner+"-"+d.Team1
else:
d.match_winner=d.match_winner+"-"+d.Team2
return d
(match.apply(win_lose,axis="columns")).match_winner.value_counts().index[0]

33 changes: 0 additions & 33 deletions Introduction-to-Data-Science/README.md

This file was deleted.

12 changes: 0 additions & 12 deletions Introduction-to-Data-Science/Rakesh/Assignment1/assignment1.sh

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions Introduction-to-Data-Science/Week-1/AdityaJain/assgn1.sh

This file was deleted.

7 changes: 0 additions & 7 deletions Introduction-to-Data-Science/Week-1/Amodh/assignment 1.sh

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions Introduction-to-Data-Science/Week-1/Dhruv/assignment1.sh

This file was deleted.

22 changes: 0 additions & 22 deletions Introduction-to-Data-Science/Week-1/KRahulReddy/Assignment 1.sh

This file was deleted.

3 changes: 0 additions & 3 deletions Introduction-to-Data-Science/Week-1/KRahulReddy/details.txt

This file was deleted.

7 changes: 0 additions & 7 deletions Introduction-to-Data-Science/Week-1/KRahulReddy/file.txt

This file was deleted.

7 changes: 0 additions & 7 deletions Introduction-to-Data-Science/Week-1/KRahulReddy/temp.txt

This file was deleted.

4 changes: 0 additions & 4 deletions Introduction-to-Data-Science/Week-1/Madhumitha/Details.txt

This file was deleted.

25 changes: 0 additions & 25 deletions Introduction-to-Data-Science/Week-1/Madhumitha/assignment1.sh

This file was deleted.

10 changes: 0 additions & 10 deletions Introduction-to-Data-Science/Week-1/Madhuparna/Assignment1.sh

This file was deleted.

10 changes: 0 additions & 10 deletions Introduction-to-Data-Science/Week-1/Niranjan/prog.sh

This file was deleted.

7 changes: 0 additions & 7 deletions Introduction-to-Data-Science/Week-1/Ramanan/Assignment1.sh

This file was deleted.

3 changes: 0 additions & 3 deletions Introduction-to-Data-Science/Week-1/Ramanan/Details.txt

This file was deleted.

1 change: 0 additions & 1 deletion Introduction-to-Data-Science/Week-1/Ramanan/Test.md

This file was deleted.

Submodule datasciencecoursera deleted from 8244a4
12 changes: 0 additions & 12 deletions Introduction-to-Data-Science/Week-1/RohitMP/prog1.sh

This file was deleted.

5 changes: 0 additions & 5 deletions Introduction-to-Data-Science/Week-1/S.R.Sahith/assg1.sh

This file was deleted.

7 changes: 0 additions & 7 deletions Introduction-to-Data-Science/Week-1/SAURABH/ASSIGNMENT1.sh

This file was deleted.

5 changes: 0 additions & 5 deletions Introduction-to-Data-Science/Week-1/SakshatRao/assignment1.sh

This file was deleted.

11 changes: 0 additions & 11 deletions Introduction-to-Data-Science/Week-1/Shashank/first.sh

This file was deleted.

5 changes: 0 additions & 5 deletions Introduction-to-Data-Science/Week-1/Siddhartha/Assignment1.sh

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions Introduction-to-Data-Science/Week-1/chandana/assignment1.sh

This file was deleted.

Loading