Question: Fix this Python code to function correctly: def getBMData ( filename ) : Assumes filename is a fully qualified filename for a

Fix this Python code to function correctly: def getBMData(filename):
"""Assumes filename is a fully qualified filename for a CSV containing
CH, MaxStaffed, WSL (int), CO (int), row_date (float)
Returns a dictioary with a list for each variable"""
data ={}
data['CH']=[]
data['CO']=[]
data['MaxStaffed']=[]
data['WSL']=[]
data['row_date']=[]
f = open(filename)
line = f.readline()
while line !='':
split = line.split(',')
data['MaxStaffed'].append(split[0])
data['CH'].append(split[1])
data['WSL'].append(split[2])
data['CO'].append(split[3])
data['row_date'].append(split[4])
line = f.readline()
f.close()
return data
import matplotlib.pyplot as plt
import numpy as np
def makeHist(data, numBins, title, xlabel, ylabel):
plt.close()
plt.hist(data, numBins)
plt.title(title)
plt.xlabel(xlabel)
plt.ylabel(ylabel)
mean = np.mean(data)
std = np.std(data)
plt.annotate('Mean: '+ str(round(mean,2))+'
'+
'SD: '+ str(round(std,2)),
fontsize =15,
xy =(0.65,0.75),
xycoords = 'axes fraction')
plt.show()
bm_dict = getBMData('FP_Paygov_CO_CH.csv')
makeHist(bm_dict['row_date'],100, 'Calls Handled for the past 24 months',
'CH',
'CO')

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 Databases Questions!