Wrong total apps count

hey there! first time using the community. I have done all the app cleaning part which my numbers match the solution notebook, but, when I run the ISOLATE FREE APPS code the android list comes out short by 2. I can’t make any sense out of this, since on the previous steps everything is matching. I have also noticed that when I log out from DQ when I get back to it I have to re-run all cells every time, is this how it’s supposed to be? thanks in advance for the helpBasics.ipynb|attachment (4.3 KB)

I think you have deleted the rows twice by running delete command twice. As a result your list comes out short by 2. You have to run the delete command only once while running the code.

Thank you for the reply! I thought that was the case, but it should be okay if I log out and re-run the whole thing just once right?

Correct. Are you still getting two values less…?

Hello @MarcusPassarinhoChav, welcome to our community.

When asking a question, make sure to follow the Technical Question Guidelines. You can also read this about how to ask a good question. When you ask the question properly you have more chances to receive a fast, accurate answer.

It is important to post a piece of well-formatted code instead of a link to a file. Also, make sure to post in our Q&A section, to where I am moving this topic now.

Answering one of your questions: yes, every time you reopen your Jupiter notebook you have to run the whole code. This is not a Dataquest feature, but a Jupyter feature. The code is saved, but the values and variables in the memory are deleted once you closed the notebook.

1 Like

still getting count error for the android apps list, but tracing back the code every step looks fine and numbers match the solution. I did run it only once to avoid double deletion. Help

Screen Shot 2020-06-29 at 2.35.47 PM Screen Shot 2020-06-29 at 2.34.38 PM Screen Shot 2020-06-29 at 2.34.27 PM Screen Shot 2020-06-29 at 2.28.47 PM

Could you provide the code file so that I can back track your code and look into the matter.

Basics (1).ipynb (21.3 KB)

Click here to view the jupyter notebook file in a new tab

Try running the dictionary and loop to clean android data separate. This would make your step correct. As you were running the conditions in the same loop it made it count two less values in the dictionary as it had to meet both if conditions simultaneusly.

android_clean = []
already_added = []
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
print('Expected length:', len(android) - 1181)
print('Actual length:', len(reviews_max))

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) # make sure this is inside the if block

Thanks! i will try it, but I would love to understand why and how it does that. Since like I’ve mentioned before, the two steps before the count I am getting the right numbers. It doesn’t make any sense. This kind of thing that throws me off when learning. I will let you know how it worked. Thank you very much for the help!