Data Frames and Charts: 2.1 Working With Dataframes
Data Frames and Charts: 2.1 Working With Dataframes
import pandas as pd
pd.read_csv?
type(ipl_auction_df)
pandas.core.frame.DataFrame
pd.set_option('display.max_columns', 7)
ipl_auction_df.head(5)
Sl.NO. PLAYER NAME AGE ... AUCTION YEAR BASE PRICE SOLD PRICE
5 rows × 26 columns
0 1 2 3 4
Sl.NO. 1 2 3 4 5
AGE 2 2 2 1 2
T-WKTS 0 18 58 31 0
CAPTAINCY EXP 0 0 0 0 0
HS 0 0 39 11 71
SIXERS 0 0 5 0 28
WKTS 15 0 29 49 0
ipl_auction_df.shape
(130, 26)
ipl_auction_df[0:5]
Sl.NO. PLAYER NAME AGE ... AUCTION YEAR BASE PRICE SOLD PRICE
5 rows × 26 columns
ipl_auction_df[-5:]
Sl.NO. PLAYER NAME AGE ... AUCTION YEAR BASE PRICE SOLD PRICE
5 rows × 26 columns
ipl_auction_df['PLAYER NAME'][0:5]
0 Abdulla, YA
1 Abdur Razzak
2 Agarkar, AB
3 Ashwin, R
4 Badrinath, S
Name: PLAYER NAME, dtype: object
0 Abdulla, YA SA
2 Agarkar, AB IND
3 Ashwin, R IND
4 Badrinath, S IND
4 Badrinath, S 2 IND
5 Bailey, GJ 2 AUS
6 Balaji, L 2 IND
7 Bollinger, DE 2 AUS
8 Botha, J 2 SA
ipl_auction_df.COUNTRY.value_counts()
IND 53
AUS 22
SA 16
SL 12
PAK 9
NZ 7
WI 6
ENG 3
ZIM 1
BAN 1
Name: COUNTRY, dtype: int64
ipl_auction_df.COUNTRY.value_counts(normalize=True)*100
IND 40.769
AUS 16.923
SA 12.308
SL 9.231
PAK 6.923
NZ 5.385
WI 4.615
ENG 2.308
ZIM 0.769
BAN 0.769
Name: COUNTRY, dtype: float64
1 4 5 7 0
2 25 21 29 11
3 6 13 8 1
73 Noffke, AA 20000
0 Abdulla, YA 50000
93 Sehwag, V 1800000
50 Kohli, V 1800000
Which players got the maximum premium offering on their base price?
ipl_auction_df[['PLAYER NAME',
'BASE PRICE',
'SOLD PRICE', 'premium']].sort_values('premium',
ascending = False)[0:5]
ipl_auction_df.groupby('AGE')['SOLD PRICE'].mean()
AGE
1 720250.000
2 484534.884
3 520178.571
Name: SOLD PRICE, dtype: float64
soldprice_by_age = ipl_auction_df.groupby('AGE')['SOLD PRICE'].mean().reset_inde
x()
soldprice_by_age
0 1 720250.000
1 2 484534.884
2 3 520178.571
Average SOLD PRICE for Different Playing Roles in Each Age Category?
0 1 Allrounder 587500.000
1 1 Batsman 1110000.000
2 1 Bowler 517714.286
3 2 Allrounder 449400.000
4 2 Batsman 654761.905
5 2 Bowler 397931.034
6 2 W. Keeper 467727.273
7 3 Allrounder 766666.667
8 3 Batsman 457692.308
9 3 Bowler 414375.000
10 3 W. Keeper 700000.000
Compare the average auction price for different ages and playing roles.
soldprice_comparison.head(5)
Which players have hit more then 80 sixes in the IPL tournament so far?
26 Gayle, CH 129
28 Gilchrist, AC 86
82 Pathan, YK 81
88 Raina, SK 97
97 Sharma, RG 82
dtype='object')