Question: Task :: Data Exploration Given the dataset and the starting code answer the questions stated on this task. Questions + Analysis 2. Data Cleaning Write

Task :: Data Exploration

  • Given the dataset and the starting code answer the questions stated on this task.

Questions + Analysis

2. Data Cleaning

Write cleaning function such that:

  • Preserves the name of the candy as a string
  • Turns all strings of 1s and 0s to a True or False
  • Turns all string percentiles into float

3. How many candies are multi-featured?

Multi-featured A candy that is more than 1 type of candy (eg. Chocolate + Caramel)

4. Clustering

Cluster/group the candies by their type.

  • Which group has the highest win percentile?
  • Which group has the lowest win percentile?
  • Does the sugar percentile of the group matter?
  • Does the price percentile matter?
  • Should candies be clustered/grouped based on multi-feature or on their single features?
  • Should candy be allowed to exist in multiple groups since some are multi-featured?

main.py

#########################################################

# Do Not Edit the Python Code Underneath #

# These lines of codes are written for the assignment #

#########################################################

dataset = None # Global Dataset variable initialization

with open('candy.csv', 'r') as datafile:

# Reading the Dataset File --> candy.csv; must be in the same directory

dataset = datafile.readlines()

# New Line removing function + map operation

removeNewLine = lambda x : x.replace(' ', '')

dataset = list(map(removeNewLine, dataset))

# Split strings to list by commas functions + map operation

commaSplit = lambda x : x.split(',')

dataset = list(map(commaSplit, dataset))

# end of file read

print('Our Candy Dataset ', dataset) # Uncomment this line to see your dataset

# You may start your code underneath this line.

# the dataset variable is accessible. You may choose to use it, or you can

# copy it via dataset.copy()

data link: https://docs.google.com/spreadsheets/d/14t9c8uqW0kFjrBjWGuQwom-IR76WbfKXT50qRtl46Kk/edit#gid=0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!