Skip to content

Instantly share code, notes, and snippets.

@alexanderawwagner
Last active June 25, 2021 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexanderawwagner/9763119faf1095724d8d2c9c4f13b643 to your computer and use it in GitHub Desktop.
Save alexanderawwagner/9763119faf1095724d8d2c9c4f13b643 to your computer and use it in GitHub Desktop.
Medium_05_Python Course-Part 05-Functions
athlets = pd.DataFrame({"Name" : ["John","Kate","Julia"],
"medal" : ["gold","silver","bronze"]})
def medalScore(df):
if df['medal'] == "gold":
score = 3
elif df['medal'] == "silver":
score = 2
elif df['medal'] == "bronze":
score = 1
else:
score = 0
return score
athlets['medalScore'] = athlets.apply(medalScore, axis=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment