We created a list (‘n_user_ratings’) containing data from the ‘rating_count_tot’ column:
n_user_ratings =  for row in apps_data[1:]: rating = float(row) n_user_ratings.append(rating) min_rating = min(n_user_ratings) max_rating = max(n_user_ratings)
Then further down in the 2nd loop, the provided answer suggests we loop through the apps_data[1:] dataset again and re-define that the rating is int/float of row…
for row in apps_data[1:]: user_ratings = int(row) if user_ratings <= 10000: user_ratings_freq['0 - 10000'] += 1
…instead of looping through the n_user_ratings list we created earlier:
for rating in n_user_ratings: if rating <= 1000: rating_count_intervals['0 - 1000'] += 1
The output I got was the same between the two scenarios.
I thought using the ‘n_user_ratings’ list would be slightly more efficient, since we’ve already created it. Is there a reason why it’s better to loop through apps_data instead or is it just a different way of doing the same thing?
Click here to open the screen in a new tab.