Screen Link:
Hello , please need help on why the function is not printing any output as expected, thank you!
My Code:
#Open csv
file_apple = open('AppleStore.csv')
file_google = open('googleplaystore.csv')
#Import file
import csv
file_apple_read = csv.reader(file_apple)
file_google_read = csv.reader(file_google)
#Put file in dataset list
dataset_apple = list(file_apple_read)
dataset_google = list(file_google_read)
# Duplicate check function
def duplicate(dataset,index):
duplicate_apps = []
unique_apps = []
for app in dataset:
name=app[index]
if name in unique_apps:
duplicate_apps.append(name)
else:
unique_apps.append(name)
print ('This is the number of duplicate apps:', len(duplicate_apps))
print ('\n')
print ('These are instances of duplicate apps', duplicate_apps[:16])
# Find duplicates in dataset
duplicate(dataset_google,0)
duplicate(dataset_apple,1)
What I expected to happen:
I tried to define a function that will find duplicates within a dataset by passing the dataset and the name of the app index. For instance, duplicate(dataset_google,0)
duplicate(dataset_apple,1)
What actually happened:
There isn't any output when I call the duplicate function for instance duplicate(dataset_google,0)
The print() line of code is not indented such that it is in the body of the function as such it doesnt print when you call the function. The function should look like this:
def duplicate(dataset,index):
duplicate_apps = []
unique_apps = []
for app in dataset:
name=app[index]
if name in unique_apps:
duplicate_apps.append(name)
else:
unique_apps.append(name)
print('This is the number of duplicate apps:', len(duplicate_apps))
print('\n')
print('These are instances of duplicate apps', duplicate_apps[:16])
Hello @doyinsolamiolaoye, thank you for the welcome! Pleased to be here to begin my data science journey.
Thank you very much for the feedback. The function is working perfectly now and output is getting printed now. Thanks again
This is the number of duplicate apps: 1181
These are instances of duplicate apps ['Quick PDF Scanner + OCR FREE', 'Box', 'Google My Business', 'ZOOM Cloud Meetings', 'join.me - Simple Meetings', 'Box', 'Zenefits', 'Google Ads', 'Google My Business', 'Slack', 'FreshBooks Classic', 'Insightly CRM', 'QuickBooks Accounting: Invoicing & Expenses', 'HipChat - Chat Built for Teams', 'Xero Accounting Software', 'MailChimp - Email, Marketing Automation']
This is the number of duplicate apps: 2
These are instances of duplicate apps ['Mannequin Challenge', 'VR Roller Coaster']