Project1: ValueError: could not convert string to float: '3.0M'

Screen Link:
https://app.dataquest.io/m/350/guided-project%3A-profitable-app-profiles-for-the-app-store-and-google-play-markets/5/removing-duplicate-entries-part-two

reviews_max = {}


for row in android_dataset[1:]:
    name = row[0]
    n_reviews = float(row[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(len(reviews_max))

What I expected to happen: The data set should have 9,659 rows

What actually happened:

ValueError                                Traceback (most recent call last)
<ipython-input-3-17ea9549b95e> in <module>
      4 for row in android_dataset[1:]:
      5     name = row[0]
----> 6     n_reviews = float(row[3])
      7 
      8     if name in reviews_max and reviews_max[name] < n_reviews:

ValueError: could not convert string to float: '3.0M'

I suspect this error comes from using the del function in a previous cell. However, using the kernel tab, I restarted and run all. In the previous cell it correctly shows I am left with 10841 rows.

Any help is appreciated. Thanks!

Hi fso00294

Welcome to the community!

You haven’t deleted the faulty data, that’s why you’re getting this error.
You’ll have to go through Screen 3 and remove the wrong data first.
After deletion you’ll have 10840 rows, then run your code from above. Then, ypu won’t get this error.

Hope this helps.

Thank you very much for the help.

Actually, I found what my error was. In a previous cell I already use the following lines:


android_dataset = android_dataset[1:]

So, when in the current cell I used the following code lines:

for row in android_dataset[1:]:

It made me incorrectly select the row numbers in the current cell.

Thanks again!