Python Programming Histogram without importing pandas or csv
Budget: $30 – $250 CAD
Deadline 5 Hours
Please view the files T008_M1_load_data.py, student-mat.csv, and
Design a function called histogram that has two input parameters: 1)takes one of the dictionaries generated in the code in the python file T008_M1_load_data.py. 2) A string which will indicate which attribute will be plotted (school,age,health,failures). The function will work with any of the dictionaries generated by the first four functions in T008_M1_load_data.py (student_age_dictionary,student_health_dictionary,...etc.)
The 4 functions were designed to create a dictionary out of data in the excel file student-mat.csv(view it in notepad to view how the data is stacked).
I have already created a function called student_list which converts the outputted dictionary into a list which can then be used to plot a histogram, it is required to incorporate this function into the function histogram. NOTE: you cannot use import csv or pandas. And since there is both numerical and string attributes you cannot use hist. hist only works with numerical values. You are required to use the function bar from Matplotlib.pyplot.
Code I have so far:
from T008_M1_load_data import *
import string
from typing import List
def student_list(dic: dict)->list:
data_list = []
for key, value in dic.items():
#Value is a list of dict
for item in value:
#Item is a dictionary
if "School" not in item.keys():
item["School"] = key
data_list.append (item)
elif "Age" not in item.keys():
item ["Age"] = key
data_list.append(item)
elif "Health" not in item.keys():
item ["Health"] = key
data_list.append (item)
elif "Failures" not in item.keys():
item ["Failures"] = key
data_list.append(item)
return data_list
Please view the files T008_M1_load_data.py, student-mat.csv, and
Design a function called histogram that has two input parameters: 1)takes one of the dictionaries generated in the code in the python file T008_M1_load_data.py. 2) A string which will indicate which attribute will be plotted (school,age,health,failures). The function will work with any of the dictionaries generated by the first four functions in T008_M1_load_data.py (student_age_dictionary,student_health_dictionary,...etc.)
The 4 functions were designed to create a dictionary out of data in the excel file student-mat.csv(view it in notepad to view how the data is stacked).
I have already created a function called student_list which converts the outputted dictionary into a list which can then be used to plot a histogram, it is required to incorporate this function into the function histogram. NOTE: you cannot use import csv or pandas. And since there is both numerical and string attributes you cannot use hist. hist only works with numerical values. You are required to use the function bar from Matplotlib.pyplot.
Code I have so far:
from T008_M1_load_data import *
import string
from typing import List
def student_list(dic: dict)->list:
data_list = []
for key, value in dic.items():
#Value is a list of dict
for item in value:
#Item is a dictionary
if "School" not in item.keys():
item["School"] = key
data_list.append (item)
elif "Age" not in item.keys():
item ["Age"] = key
data_list.append(item)
elif "Health" not in item.keys():
item ["Health"] = key
data_list.append (item)
elif "Failures" not in item.keys():
item ["Failures"] = key
data_list.append(item)
return data_list