Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

XML Data Management Native XML And XML Enabled Database Systems

Authors: Akmal Chaudhri, Awais Rashid, Roberto Zicari, John Fuller

1st Edition

0201844524, 978-0201844528

More Books

Students also viewed these Databases questions

Question

Describe Balor method and give the chemical reaction.

Answered: 1 week ago

Question

How to prepare washing soda from common salt?

Answered: 1 week ago

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago