Guided Project on Apps - error total number of cleaned data

Hi there,

I’m new to Jupyter Notebook and learning with the project about Android and iOS apps. When I want to clean the Android dataset from duplicates, I get the error ‘Index out of range’:


IndexError Traceback (most recent call last)
in
9 already_added.append(name)
10
—> 11 explore_data(android_cleaned, 0, 3, True)

in explore_data(dataset, start, end, rows_and_columns)
7 if rows_and_columns:
8 print(‘Number of rows:’, len(dataset))
----> 9 print(‘Number of columns:’, len(dataset[0]))

IndexError: list index out of range

I used following code to separate the duplicates:

android_cleaned = []
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_cleaned.append(app)
        already_added.append(name)

explore_data(android_cleaned, 0, 3, True)

The explore function is as follows:

def explore_data(dataset, start, end, rows_and_columns=False):
    dataset_slice = dataset[start:end]    
    for row in dataset_slice:
        print(row)
        print('\n')

    if rows_and_columns:
        print('Number of rows:', len(dataset))
        print('Number of columns:', len(dataset[0]))

What am I doing wrong here??

Thanks a lot for your help!

Welcome to the community @Amaryllis.

It is really difficult to understand where the problem is from your code since you’ve wrongly outlined it. You can get assistance on how to use the markdown here Guide: Using Markdown

Also I hope the main error you are experiencing may be due to indentation, you can check for the solution to correct you code. Solution

If you experience more challenges we are here to assist.

Thanks for the tips! I hope my code is readable now.

Are you still experiencing the same challenge?

Yes, I have rerunned all my code and checked for spelling errors, but still obtain the same error. I can run the explore_data function on the Android dataset without any problem.