Stuck in project on Profitable Apps guided project

Screen Link:

Learn data science with Python and R projects Code:

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 between rows
        
    if rows_and_columns:
        print('Number of rows:', len(dataset))
        print('Number of columns:', len(dataset[0]))

print(android_header)
print('\n')
explore_data(android, 0, 3, True)```

What I expected to happen:
['App', 'Category', 'Rating', 'Reviews', 'Size', 'Installs', 'Type', 'Price', 'Content Rating', 'Genres', 'Last Updated', 'Current Ver', 'Android Ver']


['Photo Editor & Candy Camera & Grid & ScrapBook', 'ART_AND_DESIGN', '4.1', '159', '19M', '10,000+', 'Free', '0', 'Everyone', 'Art & Design', 'January 7, 2018', '1.0.0', '4.0.3 and up']


['Coloring book moana', 'ART_AND_DESIGN', '3.9', '967', '14M', '500,000+', 'Free', '0', 'Everyone', 'Art & Design;Pretend Play', 'January 15, 2018', '2.0.0', '4.0.3 and up']


['U Launcher Lite – FREE Live Cool Themes, Hide Apps', 'ART_AND_DESIGN', '4.7', '87510', '8.7M', '5,000,000+', 'Free', '0', 'Everyone', 'Art & Design', 'August 1, 2018', '1.2.4', '4.0.3 and up']

What actually happened: 
['g']


['o']


['o']


['g']


Number of rows: 18
Number of columns: 1

I started the project on profitable app profiles for the App Store and google play markets and I am not able to print column names and identify columns for analysis.

@tarangds

Welcome to the community!

I ran the explore_data function you provided. I got the results that you expected.

Can you please provide the full code in your program up to this point?

from csv import reader
##The Google Play dataset##
opened_file=(‘googleplaystore.csv’)
read_file=reader(opened_file)
android=list(read_file)
android_header=android[0]
android=android[1:]

##The Applestore Play dataset##
opened_file=(‘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(row)
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]))

print(android_header)
print(’\n’)
explore_data(android, 0, 3, True)

Thank you for your reply. Its the full code.

1 Like

Both files were not opened.

Use:

opened_file=open('googleplaystore.csv')
opened_file = open('AppleStore.csv')

Thank you. It worked :-))

1 Like