The results have been change

Hello,
In lesson 13: Filtering for the Intervals, I’ve written these codes:
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
rating_count_tot =
for row in apps_data[1:]:
rating = int (row[5])
rating_count_tot.append(rating)
ratings_max=max(rating_count_tot)
ratings_min= min(rating_count_tot)
print (ratings_max)
print (ratings_min)
user_ratings_freq = {‘0-300000’:0, ‘300000-600000’:0, ‘600000-1000000’: 0, ‘1000000+’:0}
for row in apps_data[1:]:
user_ratings= float(row[5])
if user_ratings<=300000:
user_ratings_freq[‘0-300000’]+=1
elif 300000<user_ratings<=600000:
user_ratings_freq[‘300000-600000’]+=1
elif 600000 <user_ratings<= 1000000:
user_ratings_freq[‘600000-1000000’]+=1
elif user_ratings >1000000:
user_ratings_freq[‘1000000+’]+=1
print(user_ratings_freq)
and the result is 2974676
0
{‘1000000+’: 6, ‘300000-600000’: 42, ‘0-300000’: 7139, ‘600000-1000000’: 10}
But if I change from if user_ratings<=300000 to 0<user-ratings<=300000, the result becomes
2974676
0
{‘600000-1000000’: 10, ‘1000000+’: 6, ‘0-300000’: 6210, ‘300000-600000’: 42}
The frequency of 0-300000 is changed from 7139 to 6210? It means that there might be the value lower than 0. But the minimum value is 0.0?
Could you please help me address it? Thank you.

Hi @haupham.neu, welcome to the community!

0 < user_ratings <= 300000 will not include ratings of 0.0 because we have used the < symbol. If you change this to 0 <= user_ratings <= 300000, then you get the same results as user_ratings <= 300000 because we are including those 929 apps with a 0.0 rating.

1 Like

Hello!
Oh I see.Thank you so much.