Number of Columns

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

In googleplaystore and applestore dataset, there are 14 and 17 columns respectively (according to the csv file). but using the explore_data function it shows 150 and 93 columns!

here is the function:

def explore_data(dataset, start, end, rows_and_columns=False):
    dataset_slice = dataset[start:end]    
    for row in dataset_slice:
        print(row)
        print('\n') # adds a new (empty) line after each row

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

I run it like this:
explore_data(android[1:],0,5,True)

is something wrong here or maybe it is my mistake I’m not sure

This code seems okay. Mistake might be happened while getting or reading data from csv files. can you add that code as well?

PS: Please add source code under '```' So it can be render in code block.
For example:
```
Paste your code here
```

1 Like

Dear @DishinGoyani thanks for answering my question.
here is the code for reading the files
android = open(‘googleplaystore.csv’)
android = list(android)
apple = open(‘AppleStore.csv’, encoding=‘utf8’)
apple = list(apple)

2 Likes

Hi @msmohsensadr,

You forgot to use the reader function:

from csv import reader
android = open('googleplaystore.csv')
android = list(reader(android))
apple = open('AppleStore.csv', encoding='utf8')
apple = list(reader(apple))

Best,
Sahil

1 Like

Thank you so much dear @Sahil. Problem solved :smiley:

1 Like