Created
June 2, 2019 05:06
-
-
Save guerbai/e8621b9a00b05c98463c0900c50e9f3c to your computer and use it in GitHub Desktop.
将分数一栏转化为star数 #Pandas
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
def stars(row): | |
if row.country == 'Canada': | |
return 3 | |
elif row.points >= 95: | |
return 3 | |
elif row.points >= 85: | |
return 2 | |
else: | |
return 1 | |
star_ratings = reviews.apply(stars, axis='columns') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment