The mean of an array in python is not coming

Viewed 31
import csv
import numpy as np
salaries_list = []
with open('/Users/kumarabhinav/Desktop/Assignment 4 BAN 
602/emp_base_salaries_homework4.csv') as csvfile:
reader= csv.DictReader(csvfile)
empBp = {}
empOp = {}
empBf = {}
empOthrPay = {}
for row in reader:
    et = row["EmployeeType"]
    bp = row["BasePay"]
    op = row["OvertimePay"]
    bf = row["Benefits"]
    othrPay = row["OtherPay"]

    if et in empBp.keys():
        temp = empBp[et]
        #bp_hourly_rate = float(bp) / 1778
        temp.append (float(bp)/1778)
        empBp[et] = temp
    else:
        temp = []
        #bp_hourly_rate = float(bp) / 1778
        temp.append(float(bp)/1778)
        empBp[et] = temp

    if et in empOp.keys():
        temp = empOp[et]
        op_hourly_rate = float(op) / 1778
        temp.append(op_hourly_rate)
        empOp[et] = temp
    else:
        temp = []
        op_hourly_rate = float(op)/1778
        temp.append(op_hourly_rate)
        empOp[et] = temp

    if et in empBf.keys():
        temp = empOp[et]
        op_hourly_rate = float(op) / 1778
        temp.append(op_hourly_rate)
        empOp[et] = temp
    else:
        temp = []
        op_hourly_rate = float(op)/1778
        temp.append(op_hourly_rate)
        empOp[et] = temp

    if et in empOthrPay.keys():
        temp = empOp[et]
        op_hourly_rate = float(op) / 1778
        temp.append(op_hourly_rate)
        empOp[et] = temp
    else:
        temp = []
        op_hourly_rate = float(op)/1778
        temp.append(op_hourly_rate)
        empOp[et] = temp

    ht_arr = np.array(empBp)
    print("the employee base are :",ht_arr)
    ht_arr1 = np.array(empOp)
    print("The Employee Other pay are:",ht_arr1)
    ht_arr2 = np.array(empBf)
    print("the benefits of the employees are :",ht_arr2)
    ht_arr3 = np.array(empOthrPay)
    print("the Other pay is :", ht_arr3)
    print("the mean hieght is :", ht_arr.mean()) 
  • Here the error is coming ---

Error -

 File "/Users/kumarabhinav/PycharmProjects/Files Project/sp1411_Homework4_Rough.py", line 95, in <module>
    print("the mean hieght is :", ht_arr.mean())
TypeError: unsupported operand type(s) for /: 'dict' and 'int'**

# There is a CSV file of data containing ID, Employee Name, Job Tiltle (IC/MRG/APRT), Employeetype, EMployeetypeCode,Basepay, OvertimePay,OtherPay,Benefits

We have to calcuulate hourly rate of the each type of employee(IC/MGR/APRG). Hour rate is 1778.

Then we have to print it in an array using numpy only

then we have to print Mean & Standard deviation of the employess. -- Here i am getting error.

Then we have to write it in a text file. txt

0 Answers
Related