1st Guided Project: Profitable Apps

Screen Link: <https://app.dataquest.io/m/350/guided-project%3A-profitable-app-profiles-for-the-app-store-and-google-play-markets/2/opening-and-exploring-the-data

I’m stuck on trying to open, read and list the apple and android dataset. I keep getting the below error message stating “android_header” is not defined.

My Code:

What I expected to happen:
Sorry I couldn’t post more than one image. I expected to have this dataset listed out.

What actually happened:
I kept getting the following error:
NamError: name “andorid_header” is not defined. It seems it is to me, so I don’t know what I’m missing.

Hello @redkraftllc and welcome to the community!

First, avoid posting images of the code. When you post a well-formatted piece of code it is easier for people to help you. If you don’t know how to that, take a look at the Technical Question Guidelines. You should also post the entire description of the error raised.

With the information you provided, I can see the problem is a typo, since the error says:

NamError: name "andorid_header" is not defined

At some point, you typed andorid_header instead of android_header. But as you did not post the full error, I cannot know which line of code is causing it. In fact, as you posted an image of two cells, I do not even know which cell is raising the error.

When you format your question properly, you have more chances of receiving a fast, accurate answer.

1 Like

Thank you for your response and for sharing useful tips on how to post a topic. It’s my first time posting here so kindly bear with me. Here’s the full code below. I wish it was a misspelling, but it isn’t, as I accidentally typed that on here.

from csv import reader

#The Google Play Data Set ##

opened_file = open("googleplaystore.csv")
read_file = reader(opened_file)
android = list(read_file)
android_header = android[0]
android = android[1:]

#The Apple Store Data Set ##

opened_file = open("AppleStore.csv")
read_file = reader(opened_file)
ios = list(read_file)
ios_header = ios[0]
ios = ios[1:]

def explore_data(dataset, start, end, rows_and_columns=False):
    dataset_slice = dataset[start:end]    
    for row in dataset_slice:
        print('\n') # adds a new (empty) line between rows
    if rows_and_columns:
        print('Number of rows:', len(dataset))
        print('Number of columns:', len(dataset[0]))

explore_data(android, 0, 3, True)

##This happens after I run the code above##

NameErrorTraceback (most recent call last)
<ipython-input-2-7cde305bf793> in <module>()
      9         print('Number of columns:', len(dataset[0]))
---> 11 print(android_header)
     12 print('\n')
     13 explore_data(android, 0, 3, True)

NameError: name 'android_header' is not defined

That’s OK, but please notice that your code is not properly formatted yet.

Your problem is in the following line:


The error says the variable android_header is not defined, but you defined in the first cell. So I’m guessing you probably ran the second cell before running the first one.

1 Like

Perfect! How right you are. I can’t believe the answer was that obvious. Thanks so much!

1 Like