Aug 29, 2024
cricket_test_match_data.csv
).import pandas as pd
df = pd.read_csv('path/to/cricket_test_match_data.csv')
df.rename()
method:
No
to Not Out
HS
to Highest Innings Score
BF
to Balls Faced
SR
to Strike Rate
df.isnull().any()
df['Balls Faced'].fillna(0, inplace=True)
df['Strike Rate'].fillna(0, inplace=True)
df.duplicated()
df = df.drop_duplicates()
df['Rookie Year'] = df['Span'].str.split('-').str[0]
df['Final Year'] = df['Span'].str.split('-').str[1]
df = df.drop(columns=['Span'])
astype()
method:
df['Matches'] = df['Matches'].astype(int)
df['Batting Strike Rate'] = df['Batting Strike Rate'].astype(float)
df['Career Length'] = df['Final Year'] - df['Rookie Year']
avg_career_length = df['Career Length'].mean()
avg_strike_rate = df[df['Career Length'] > 10]['Batting Strike Rate'].mean()
count_before_1960 = df[df['Rookie Year'] < 1960].count()
df.groupby('Country')['Highest Innings Score'].max()