Screen Link:
App Profile Recommendation | Dataquest
My Code:
This is the first piece of code. I think i understand this. the idea is to create a dictionary with highest number of reviews. I don't understand the second block of code
reviews_max = {}
for app in android:
name = app[0]
n_reviews = float(app[3])
if name in reviews_max and reviews_max[name] < n_reviews:
reviews_max[name] = n_reviews
elif name not in reviews_max:
reviews_max[name] = n_reviews
Second block says the below.
-
Why do we need this bit ? Isn’t the dictionary above good enough with unique entry - names and with highest number of review?
-
Why are we using the dictionary to clean the original dataset ? What is that in original dataset which is not yet in dictionary - i think that’s the key to the question . Or are we saying that dictionary (reviews_max) has duplicates - but how is that possible, since first piece of code will not put in a new entry for the same app, or will it ?
-
Finally, are we saying that android_clean is the final dataset that we are targetting ?
android_clean =
already_added =
for app in android:
name = app[0]
n_reviews = float(app[3])
if (reviews_max[name] == n_reviews) and (name not in already_added):
android_clean.append(app)
already_added.append(name)
What I expected to happen:
Just the first piece of code doing the work
What actually happened:
two pieces of code
Replace this line with the output/error
<!--Enter other details below: -->