Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created Dec 21, 2020
Embed
What would you like to do?
df.Rank = df.Rank.apply(lambda x: int(x.split("#")[1]) if type(x) == np.str else x)
df.Pay = df.Pay.apply(lambda x: float(x.split(" ")[0].split("$")[1]))
df.Endorsements = df.Endorsements.apply(lambda x: float(x.split(" ")[0].split("$")[1]))
df["Salary/Winnings"].replace("-",'$nan M',inplace=True)
df["Salary/Winnings"] = df["Salary/Winnings"].apply(lambda x: float(x.split(" ")[0].split("$")[1]))
df.Sport.replace({"Soccer":"Football",
"Football":"American Football",
"Mixed Martial Arts":"MMA",
"Auto racing":"Racing",
"Auto Racing":"Racing",
"Basketbal":"Basketball",
},inplace=True)
df.columns = ['Rank', 'Name', 'Pay', 'Salary_Winnings', 'Endorsements', 'Sport', 'Year']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment