Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created December 21, 2020 12:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save amankharwal/c5e3897cb608c5b8ac7da73453fb8460 to your computer and use it in GitHub Desktop.
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