Number of Columns

Screen Link:

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('\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:

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)


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))


1 Like

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

1 Like