Hello guys!
I am cleaning the data for the GoogleStore dataset and while writing a piece fo code I obtained the following:
My Code:
apps_and_reviewsmax= {}
android_clean = []
already_added = []
for app in apps_android:
name = app[0]
n_reviews = float(app[2])
if name in apps_and_reviewsmax and apps_and_reviewsmax[name] < n_reviews:
apps_and_reviewsmax[name] = n_reviews
if name not in apps_and_reviewsmax:
apps_and_reviewsmax[name] = n_reviews
if n_reviews == apps_and_reviewsmax[name] and name not in already_added:
already_added.append(name)
android_clean.append(app)
print(len(apps_and_reviewsmax))
print('\n')
print(len(android_clean))
print('\n')
print(android_clean[:5])
What I expected to happen was that the results of apps_reviewsmax and android_clean were the same : 9659.
Instead apps_reviewsmax gives 9659
and android_clean gives 8196
I replaced the comparison operator β==β with the logical operator βisβ and it worked.
I am interested to know why as for my knowledge == means equal ?
so what happened in the loop with β==β ? why it was delating more rows?
thank you!!