Last active
June 25, 2021 14:18
-
-
Save alexanderawwagner/9763119faf1095724d8d2c9c4f13b643 to your computer and use it in GitHub Desktop.
Medium_05_Python Course-Part 05-Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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