There is an exercise I have found on Kaggle which defines my purpose as:
We'd like to host these wine reviews on our website, but a rating system ranging from 80 to 100 points is too hard to understand - we'd like to translate them into simple star ratings. A score of 95 or higher counts as 3 stars, a score of at least 85 but less than 95 is 2 stars. Any other score is 1 star.
Also, the Canadian Vintners Association bought a lot of ads on the site, so any wines from Canada should automatically get 3 stars, regardless of points.
Create a series
star_ratingswith the number of stars corresponding to each review in the dataset.
And I wrote this code with the hope to serve my purpose:
def stars(reviews):
for i,pons in enumerate(reviews.points):
if pons < 85:
reviews.points[i] = "1 star"
elif pons <95:
reviews.points[i] = "2 stars"
elif (pons >= 95):
reviews.points[i] = "3 stars"
for i,cons in reviews.country:
if cons == "Canada":
reviews.points[i] = "3 stars"
star_ratings = reviews.apply(stars, axis = "columns")
This answer did not work for me as I keep getting the
TypeError: 'int' object is not iterable
Why my for loop keeps on giving me this error?

reviews.pointsis an integer. You can't iterate over a single integer.