CODE:
opened_file = open('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
no_of_user_ratings = []
for row in apps_data[1:]:
no_of_user_ratings.append(int(row[5]))
print(max(no_of_user_ratings))
print(min(no_of_user_ratings))
user_ratings_freq = {'<= 600000':0,'600000-1200000':0,'1200000-1800000':0,'1800000-2400000':0,'> 2400000':0}
for row in apps_data[1:]:
user_ratings = int(row[5])
if user_ratings <= 600000:
user_ratings_freq['<= 600000'] += 1
elif 600000 < user_ratings <= 1200000:
user_ratings_freq['600000 - 1200000'] += 1
elif 1200000 < user_ratings <= 1800000:
user_ratings_freq['1200000 - 1800000'] += 1
elif 1800000 < user_ratings <= 2400000:
user_ratings_freq['1800000 - 2400000'] += 1
elif user_ratings > 2400000:
user_ratings_freq['> 2400000'] += 1
print(user_ratings_freq)
ERROR:
KeyErrorTraceback (most recent call last)
<ipython-input-1-38eb15cd08bf> in <module>()
25
26 elif 1800000 < user_ratings <= 2400000:
---> 27 user_ratings_freq['1800000 - 2400000'] += 1
28
29 elif user_ratings > 2400000:
KeyError: '1800000 - 2400000'
I choose 5 intervals…max(no_of_user_ratings) gave me something around 29,74,000
why is there a key error here?..the key exists in the dictionary I created…help