Answered step by step
Verified Expert Solution
Question
1 Approved Answer
candy_reader.py candy.csv im not really sure how to code this at all if anyone could help U4A - Application of Functional Programming Assignment Task ::
candy_reader.py
candy.csv
im not really sure how to code this at all if anyone could help
U4A - Application of Functional Programming Assignment Task :: Data Exploration Given the dataset and the starting code answer the questions stated on this task. Read the article: The Ultimate Halloween Candy Ranking Dataset Information Dataset Name: Number of Rows: (Records) candy.csv csv files are 'Comma Separated Values' which help us contain values There are 85 different candies that have been analyzed in this dataset There are 13 different features in this dataset. The very first feature is the name of the candy. Number of Columns : (Features/Variables) Features Explanation: There are 13 unique features to each candy bar. The features from 2 to 18 are binary - 1: True, 0: False The features from 11 to 13 are decimals to represent a percentile (8 to 1.0) 01. Name of the Candy 02. chocolate Does it contain chocolate? 03. fruity Is it fruit flavored? 84. caramel Is there caramel in the candy? 85. peanut almondy Does it contain peanuts, peanut butter or almonds? Request edit acce (VOLI SOFYT LUATO CU CELE My Features Explanation: There are 13 unique features to each candy bar. The features from 2 to 18 are binary - 1: True, e: False The features from 11 to 13 are decimals to represent a percentile (to 1.0) 01. Name of the Candy 82. chocolate Does it contain chocolate? 03. fruity Is it fruit flavored? 04. caramel Is there caramel in the candy? 85. peanutalmondy Does it contain peanuts, peanut butter or almonds? 06. nougat Does it contain nougat? 07. crispedricewafer Does it contain crisped rice, wafers, or a cookie component? 08. hard Is it a hard candy? 09. bar Is it a candy bar? 10. pluribus Is it one of many candies in a bag or box (1)? or single (0) 11. sugarpercent The percentile of sugar it falls under within the data set, 12. pricepercent The unit price percentile compared to the rest of the set. 13. winpercent The overall win percentage according to 269, ee matchups 1144LEP Datasat Analysis 1 Request edit acc Questions + Analysis 1. Functional Programming Warm-up Which candy has the longest name? 2. Data Cleaning Write a cleaning function such that: Preserves the name of the candy as a string Turns all strings of 1s and Os to a True or False Turns all string percentiles into float (Write a function, then map that function to the entire list of candies) Take advantage of mapping and lambda 3. How many candies are multi-featured? Multi-featured - A candy that is more than 1 type of candy (eg. Chocolate + Caramel) I 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? 5. Extreme Analysis (sugar percentile, price percentile, win percentile) What is the best hard candy? What is the worst hard candy? What is the average hard candy? Request edit acces 5. Extrema Analysis (sugar percentile, price percentile, win percentile) What is the best hard candy? What is the worst hard candy? What is the average hard candy? What is the best candy bar? What is the worst candy bar? What is the average candy bar? What is the best pluribus? What is the worst pluribus? What is the average pluribus? What would be the best healthiest candy? Last Question. Is it better to be multi-featured or single-featured candy in terms of performance of the candy winning? Feel free to try any data analytic practices you pave learned in Data Management U4L4 - FP Dataset Analysis, 2 Instructions You are to use the two given files to help you answer the questions on page 2 Throughout the assignment, you do not need to use functional programming I just want to see your Python Skills. There shouldn't be any reason to use OOP however. Instructions You are to use the two given files to help you answer the questions on page 2 Throughout the assignment, you do not need to use functional programming. I just want to see your Python Skills. There shouldn't be any reason to use OOP however. You are given two files: File 1: candy.csv ... you do not need to edit this file, you just need it in the same directory/location as your python file File 2: candy_reader.py ... if you are using repl.it you can just copy and paste the contents inside the main.py while you copy over the candy.csv in the repl.it as well. WARNING: If you didn't follow my instructions, earlier in the year, of putting your indentations to spaces and to a size of 4, you may run into an error; therefore, you may need to copy the code by retyping it Do not edit any of the code that I said not to except for the area I said you can "uncomment What to hand-in 1. Your new main.py that you used to help answer the questions on page 2. Use: studentnumber.py 2. A write up with the answers of the questions. Some are open ended and opinionated, so it will require personal analysis. Rubric 1 0 The student has submitted a completed code that helped them through the assignment The student has submitted all files and document in the proper format 0 3 2. Adequate Is Allempled 0-Incomplete What to hand-in 1. Your new main.py that you used to help answer the questions on page 2. Use: studentnumber.py 2. A write up with the answers of the questions. Some are open ended and opinionated, so it will require personal analysis. 0 Rubric The student has submitted a completed code that helped them through the assignment The student has submitted all files and document in the proper format 1 0 4 Stolar 2- Adequate 1. Attempted 0-Incomplete Standard 4 3 2 1 0 The student has answered the questions listed on page 2 with accuracy and clarity The student has provided an excellent showcase of python skills throughout the assignment 4 3 2 1 0 U4L4 - FP Dataset Analysis, 3 # 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', ') as datafile: Reading the Dataset File --> candy.csv: must be in the same directory dataset - datafile.readlines () New Line in removing function + map operation removeNewtine - lambda * : *.replace(" ', ) dataset - list (map (removedewline, dataset)) Split strings to list by commas functions - map operation comma Split - lambda * : *.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 ( O O 0 0 2000000 corporate 100 3 One One quarter AH And joy Baby Bostadens Candy Carmel Agile Pops Charleston Chow Cewey Lamondul Chic COS 0 0 0 0 0000000 SOCO ECOS GEOGEEE 0 O 0 0 0 O O 0 0 O 00 O 0 0 Durs 000 0 0 0 O . O 0 0 0 O 0 O O 0 . . D 0 O 0 0 0 0 0 0 D O 0 0 . . 0 0 ECON 0 0 0 0 D GEEN the truly care prawiamondyguard or parecen procent werden o 0 1 1 73.1999 000001 64.971725 1 O 0 0 1 600 D 0 51000098 67.50836 0 0 Ooo 0 011 116 32.261050 0 O 0 00 0 + 011 550999946.110806 0 0 0 0 + 0 . 510 5234101 1 0 001 485 1 0 78700002 50.347546 1 1 1 700002 54.54547 0 D 1 0 0 0 0 3120000 1000 21417004 0 0 OOO 1 0 30499993010263 1 0 0 0 1 0 32499999 34517881 1 001 5138975037 D 1 1 51 601762 0 + 1 DART 24 0 1 O 1 731199 0 + 509999842272070 0 Oto 34000002 5466556 0 1 0 0 1 120000224 0 . 0 010 D 0 1 D 49 29.10 0 1 OD 4500001 46.78334 0 0 0 0 0 1 45 455711914 0 0 000 405 485 341 0 D OOO 1 55514123 O 900 1 AS 1 0 000 465 2.176772 1 127 000000002 55.375454 1 D 0 45000001 1 9170962.248 0 0 1 43000009 91790918 56.490501 0 0 1 0 43000001 91 21122 0 1 0 010 1 000002 O So 28.127839 0 OOO 1 51005721995 O 101 312999 50999976789 O . + 0 0 0 0 116 413 0 D 0 Oo 046 1 104 1056 0 000 O 20 3700001 52711322 1 1 0 0 0 4099 66100002714600 1 0 0 OOO 1 824 1 65100002 68.574585 O 0 000 1 1 O 1 0 BTS 324644.41179 000 1 + 1 09 Se 56.004072 11 001 10000 735 1 1 0 001 7311999 44100001 0.000701 1 0 0 0 0 1 66000001 54.35334 1 O 0 001 3126000001 672954 1 D 1 001 31299990 1799 5452451 D 1 0 1 + 400M 55354046 + 0 0 1 7670000 70726041 0 101 3129999 76700002 664706 0 1 O 00 1 0 97600001 22445341 0 OOO 1 22 324 30446 1 1 001 465 76700002 45.265 1 000 1 592 0 1000026 00 1 093000002 O 1 010 023 37.722390 1 8000 83700001 41265611 0 O 0 0 1 SA 1 0 D 196 37 348522 1 000 00002 1 O 27100001 157 1 0 0 0 0 200000 6510000218029 1 1 65100012 13:45479 1 o 1 OOO 0 0 68900002 72.667001 0 D 731 1 1 964 35 2015 0 00 1 00001 000001 6572 0 1 1 7319 06 29.703091 0 + ET 2790000142849144 1 0 0 00 1 22 081 0 0 4722 0 000 1 90 1 22 63814 0 D 0 0 0 1 22 50 1 SRO O 00 2009 97000 378 0 1 O Oto 1 2008 116 45.92 1 1 1 001 546 1 1 68100002 1.67382 1 101 0 68900002 50.5251 0 00 100 0 1 156 50.8399 0 0 0 1 6999999 196 529 0 1 0 1 15000 22 67.037620 0 1 D 0 ot 1 1 SO0001 DO 34.370 D 0 0 1 1997 767000023343755 1 O OOO 41300000 3249999 32230995 0 + 0 OOO 0 1 170 27385 0 0 0 60300 1 D 19654861111 0 oto 60300 DO 4T 0 00 3129999 510200 ST 0 00 1 173099 091 57 1 O O 0 1 094965250 O 00 1 3120000 255 47.173229 1 0 1 0 101 545 50500002 542014 1 0 000 196 45 46622 + O Oto 0000002 116 30.01189 + 0 O Go 1 3129009 1 3129999443755 0 Oto o 20609 41904308 1 D D 1 0 0 1 44.524113 O 0 0 D O 0 0 0 O . . 0 0 0 Dum Dure Fruit Chuw Fun Op Gostoper Harbe Gold Bars Habo Happy Cola urbo Sou Beans HubeTwin Snake Hershey's Hershey's Grocka Hershey's Choco Hershey's Special Dark Juwbus Junior Male KEK Lilly Tally Load Levers biggur Peanut butter MAMS MAMA Mke & MR Oude My Way MayWay Might Miky Way Simply Crane Monda Mr Good Nerds Neste Burger Neste Oruch NLD Now & Ler Payday Peanu MAM Pets Pop Roche Hedvin Ro's Mines Reese's Peanut Butter Respieces Red with preces Role Root Beer Bar Runt S Sorginal Seberry Neste martes Srecandy Snickers Snickers Crepe Sour Patch Kids Sour Patch Tricksters Status Strawberry bonbon Selai Su Day Super Bube Swedish Tootsie Pop Tootsie Rolle Tosts Hell de Toate Rosar Troll Sou Bles Two Tui Watas Wels Frul Snacks Werthes Original Caramel Whappers 0 0 O 0 O 0 0 0 G WER gp D 1 0 O 0 0 @ O 0 0 0 0 O 0 0 0 O OTO O 0 O O O . GEOS O 0 O 0 O O 0 0 0 0 0 . 0 O 0 O O O 0 0 0 O 0 0 0 0 O O 0 D 0 0 0 O O D U4A - Application of Functional Programming Assignment Task :: Data Exploration Given the dataset and the starting code answer the questions stated on this task. Read the article: The Ultimate Halloween Candy Ranking Dataset Information Dataset Name: Number of Rows: (Records) candy.csv csv files are 'Comma Separated Values' which help us contain values There are 85 different candies that have been analyzed in this dataset There are 13 different features in this dataset. The very first feature is the name of the candy. Number of Columns : (Features/Variables) Features Explanation: There are 13 unique features to each candy bar. The features from 2 to 18 are binary - 1: True, 0: False The features from 11 to 13 are decimals to represent a percentile (8 to 1.0) 01. Name of the Candy 02. chocolate Does it contain chocolate? 03. fruity Is it fruit flavored? 84. caramel Is there caramel in the candy? 85. peanut almondy Does it contain peanuts, peanut butter or almonds? Request edit acce (VOLI SOFYT LUATO CU CELE My Features Explanation: There are 13 unique features to each candy bar. The features from 2 to 18 are binary - 1: True, e: False The features from 11 to 13 are decimals to represent a percentile (to 1.0) 01. Name of the Candy 82. chocolate Does it contain chocolate? 03. fruity Is it fruit flavored? 04. caramel Is there caramel in the candy? 85. peanutalmondy Does it contain peanuts, peanut butter or almonds? 06. nougat Does it contain nougat? 07. crispedricewafer Does it contain crisped rice, wafers, or a cookie component? 08. hard Is it a hard candy? 09. bar Is it a candy bar? 10. pluribus Is it one of many candies in a bag or box (1)? or single (0) 11. sugarpercent The percentile of sugar it falls under within the data set, 12. pricepercent The unit price percentile compared to the rest of the set. 13. winpercent The overall win percentage according to 269, ee matchups 1144LEP Datasat Analysis 1 Request edit acc Questions + Analysis 1. Functional Programming Warm-up Which candy has the longest name? 2. Data Cleaning Write a cleaning function such that: Preserves the name of the candy as a string Turns all strings of 1s and Os to a True or False Turns all string percentiles into float (Write a function, then map that function to the entire list of candies) Take advantage of mapping and lambda 3. How many candies are multi-featured? Multi-featured - A candy that is more than 1 type of candy (eg. Chocolate + Caramel) I 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? 5. Extreme Analysis (sugar percentile, price percentile, win percentile) What is the best hard candy? What is the worst hard candy? What is the average hard candy? Request edit acces 5. Extrema Analysis (sugar percentile, price percentile, win percentile) What is the best hard candy? What is the worst hard candy? What is the average hard candy? What is the best candy bar? What is the worst candy bar? What is the average candy bar? What is the best pluribus? What is the worst pluribus? What is the average pluribus? What would be the best healthiest candy? Last Question. Is it better to be multi-featured or single-featured candy in terms of performance of the candy winning? Feel free to try any data analytic practices you pave learned in Data Management U4L4 - FP Dataset Analysis, 2 Instructions You are to use the two given files to help you answer the questions on page 2 Throughout the assignment, you do not need to use functional programming I just want to see your Python Skills. There shouldn't be any reason to use OOP however. Instructions You are to use the two given files to help you answer the questions on page 2 Throughout the assignment, you do not need to use functional programming. I just want to see your Python Skills. There shouldn't be any reason to use OOP however. You are given two files: File 1: candy.csv ... you do not need to edit this file, you just need it in the same directory/location as your python file File 2: candy_reader.py ... if you are using repl.it you can just copy and paste the contents inside the main.py while you copy over the candy.csv in the repl.it as well. WARNING: If you didn't follow my instructions, earlier in the year, of putting your indentations to spaces and to a size of 4, you may run into an error; therefore, you may need to copy the code by retyping it Do not edit any of the code that I said not to except for the area I said you can "uncomment What to hand-in 1. Your new main.py that you used to help answer the questions on page 2. Use: studentnumber.py 2. A write up with the answers of the questions. Some are open ended and opinionated, so it will require personal analysis. Rubric 1 0 The student has submitted a completed code that helped them through the assignment The student has submitted all files and document in the proper format 0 3 2. Adequate Is Allempled 0-Incomplete What to hand-in 1. Your new main.py that you used to help answer the questions on page 2. Use: studentnumber.py 2. A write up with the answers of the questions. Some are open ended and opinionated, so it will require personal analysis. 0 Rubric The student has submitted a completed code that helped them through the assignment The student has submitted all files and document in the proper format 1 0 4 Stolar 2- Adequate 1. Attempted 0-Incomplete Standard 4 3 2 1 0 The student has answered the questions listed on page 2 with accuracy and clarity The student has provided an excellent showcase of python skills throughout the assignment 4 3 2 1 0 U4L4 - FP Dataset Analysis, 3 # 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', ') as datafile: Reading the Dataset File --> candy.csv: must be in the same directory dataset - datafile.readlines () New Line in removing function + map operation removeNewtine - lambda * : *.replace(" ', ) dataset - list (map (removedewline, dataset)) Split strings to list by commas functions - map operation comma Split - lambda * : *.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 ( O O 0 0 2000000 corporate 100 3 One One quarter AH And joy Baby Bostadens Candy Carmel Agile Pops Charleston Chow Cewey Lamondul Chic COS 0 0 0 0 0000000 SOCO ECOS GEOGEEE 0 O 0 0 0 O O 0 0 O 00 O 0 0 Durs 000 0 0 0 O . O 0 0 0 O 0 O O 0 . . D 0 O 0 0 0 0 0 0 D O 0 0 . . 0 0 ECON 0 0 0 0 D GEEN the truly care prawiamondyguard or parecen procent werden o 0 1 1 73.1999 000001 64.971725 1 O 0 0 1 600 D 0 51000098 67.50836 0 0 Ooo 0 011 116 32.261050 0 O 0 00 0 + 011 550999946.110806 0 0 0 0 + 0 . 510 5234101 1 0 001 485 1 0 78700002 50.347546 1 1 1 700002 54.54547 0 D 1 0 0 0 0 3120000 1000 21417004 0 0 OOO 1 0 30499993010263 1 0 0 0 1 0 32499999 34517881 1 001 5138975037 D 1 1 51 601762 0 + 1 DART 24 0 1 O 1 731199 0 + 509999842272070 0 Oto 34000002 5466556 0 1 0 0 1 120000224 0 . 0 010 D 0 1 D 49 29.10 0 1 OD 4500001 46.78334 0 0 0 0 0 1 45 455711914 0 0 000 405 485 341 0 D OOO 1 55514123 O 900 1 AS 1 0 000 465 2.176772 1 127 000000002 55.375454 1 D 0 45000001 1 9170962.248 0 0 1 43000009 91790918 56.490501 0 0 1 0 43000001 91 21122 0 1 0 010 1 000002 O So 28.127839 0 OOO 1 51005721995 O 101 312999 50999976789 O . + 0 0 0 0 116 413 0 D 0 Oo 046 1 104 1056 0 000 O 20 3700001 52711322 1 1 0 0 0 4099 66100002714600 1 0 0 OOO 1 824 1 65100002 68.574585 O 0 000 1 1 O 1 0 BTS 324644.41179 000 1 + 1 09 Se 56.004072 11 001 10000 735 1 1 0 001 7311999 44100001 0.000701 1 0 0 0 0 1 66000001 54.35334 1 O 0 001 3126000001 672954 1 D 1 001 31299990 1799 5452451 D 1 0 1 + 400M 55354046 + 0 0 1 7670000 70726041 0 101 3129999 76700002 664706 0 1 O 00 1 0 97600001 22445341 0 OOO 1 22 324 30446 1 1 001 465 76700002 45.265 1 000 1 592 0 1000026 00 1 093000002 O 1 010 023 37.722390 1 8000 83700001 41265611 0 O 0 0 1 SA 1 0 D 196 37 348522 1 000 00002 1 O 27100001 157 1 0 0 0 0 200000 6510000218029 1 1 65100012 13:45479 1 o 1 OOO 0 0 68900002 72.667001 0 D 731 1 1 964 35 2015 0 00 1 00001 000001 6572 0 1 1 7319 06 29.703091 0 + ET 2790000142849144 1 0 0 00 1 22 081 0 0 4722 0 000 1 90 1 22 63814 0 D 0 0 0 1 22 50 1 SRO O 00 2009 97000 378 0 1 O Oto 1 2008 116 45.92 1 1 1 001 546 1 1 68100002 1.67382 1 101 0 68900002 50.5251 0 00 100 0 1 156 50.8399 0 0 0 1 6999999 196 529 0 1 0 1 15000 22 67.037620 0 1 D 0 ot 1 1 SO0001 DO 34.370 D 0 0 1 1997 767000023343755 1 O OOO 41300000 3249999 32230995 0 + 0 OOO 0 1 170 27385 0 0 0 60300 1 D 19654861111 0 oto 60300 DO 4T 0 00 3129999 510200 ST 0 00 1 173099 091 57 1 O O 0 1 094965250 O 00 1 3120000 255 47.173229 1 0 1 0 101 545 50500002 542014 1 0 000 196 45 46622 + O Oto 0000002 116 30.01189 + 0 O Go 1 3129009 1 3129999443755 0 Oto o 20609 41904308 1 D D 1 0 0 1 44.524113 O 0 0 D O 0 0 0 O . . 0 0 0 Dum Dure Fruit Chuw Fun Op Gostoper Harbe Gold Bars Habo Happy Cola urbo Sou Beans HubeTwin Snake Hershey's Hershey's Grocka Hershey's Choco Hershey's Special Dark Juwbus Junior Male KEK Lilly Tally Load Levers biggur Peanut butter MAMS MAMA Mke & MR Oude My Way MayWay Might Miky Way Simply Crane Monda Mr Good Nerds Neste Burger Neste Oruch NLD Now & Ler Payday Peanu MAM Pets Pop Roche Hedvin Ro's Mines Reese's Peanut Butter Respieces Red with preces Role Root Beer Bar Runt S Sorginal Seberry Neste martes Srecandy Snickers Snickers Crepe Sour Patch Kids Sour Patch Tricksters Status Strawberry bonbon Selai Su Day Super Bube Swedish Tootsie Pop Tootsie Rolle Tosts Hell de Toate Rosar Troll Sou Bles Two Tui Watas Wels Frul Snacks Werthes Original Caramel Whappers 0 0 O 0 O 0 0 0 G WER gp D 1 0 O 0 0 @ O 0 0 0 0 O 0 0 0 O OTO O 0 O O O . GEOS O 0 O 0 O O 0 0 0 0 0 . 0 O 0 O O O 0 0 0 O 0 0 0 0 O O 0 D 0 0 0 O O D Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started