import pandas as pd
import [Link] as plt
print('===============CSKM Public School================')
print('= =')
print('= Welcome to Employee Salary Module =')
print('= =')
print('=================================================')
dfemp = pd.read_csv('[Link]',
header=None,
names=['empno','name','department','salary'])
choice = 0
while(choice != 6):
print('Choices for the module')
print('1. Add a new employee')
print('2. Update Emplpyee')
print('3. Delete Employee')
print('4. View Employees')
print('5. View Charts')
print('6. Exit')
choice = int(input('Enter your choice : '))
if(choice == 1):
empno = int(input('Input Employee Number : '))
ename = input('Input Employee Name : ')
dept = input('Input Department : ')
salary = input('Input Salary : ')
noofemployee = len(dfemp)
[Link][noofemployee] = [empno,ename,dept,salary]
print(dfemp)
dfemp.to_csv('[Link]',header=False,index=False)
elif (choice == 2):
empno = int(input('Enter Employee Number : '))
print([Link][dfemp['empno'] == empno])
indexno = [Link][dfemp['empno'] == empno].index
print('1. Update Employee Number')
print('2. Update Name')
print('3. Update Department')
print('4. Update Salary')
updatechoice = int(input('Enter your choice for update : '))
if (updatechoice == 1):
newempno = int(input('Enter new employee number : '))
[Link][indexno,'empno'] = newempno
dfemp.to_csv('[Link]',header=False,index=False)
elif (updatechoice == 2):
newempname = input('Enter new employee Name : ')
[Link][indexno,'name'] = newempname
dfemp.to_csv('[Link]',header=False,index=False)
elif (updatechoice == 3):
newempdept = input('Enter new employee Department : ')
[Link][indexno,'department'] = newempdept
dfemp.to_csv('[Link]',header=False,index=False)
elif (updatechoice == 4):
newempsal = input('Enter new employee Salary : ')
[Link][indexno,'salary'] = newempsal
dfemp.to_csv('[Link]',header=False,index=False)
print([Link][dfemp['empno'] == empno])
print('----Employee Record Updated----')
elif (choice == 3):
empno = int(input('Enter Employee Number : '))
print([Link][dfemp['empno'] == empno])
indexno = [Link][dfemp['empno'] == empno].index
confirm = input('Are you sure you want to delete it (Y/N) : ')
if (confirm == 'Y' or confirm == 'y'):
dfemp = [Link](indexno)
dfemp.to_csv('[Link]',header=False,index=False)
print('---------- Record Deleted ---------')
elif (choice == 4):
print('1. Display all ')
print('2. Display top ___ records')
print('3. Display bottom ___ records')
print('4. Display on the basis of department')
dispchoice = int(input('Enter your choice'))
if (dispchoice == 1):
print(dfemp)
elif (dispchoice == 2):
top = int(input('Enter how many top records to be displayed : '))
print([Link](top))
elif (dispchoice == 3):
bottom = int(input('Enter how many bottom records to be displayed : '))
print([Link](bottom))
elif (dispchoice == 4):
dept = input('Enter Department Name : ')
print([Link][dfemp['department'] == dept])
elif (choice == 5):
print('1. Bar Chart - Department wise salary')
print('2. Department Wise Total Salary - Line Chart')
print('3. Department Wise Average Salary - Line Chart')
print('4. Back Menu')
chartchoice = int(input('Enter your choice : '))
if (chartchoice == 1):
dftemp = [Link] ('department').aggregate('sum')
depts = [Link].to_list()
salarysum = dftemp['salary']
[Link](depts,salarysum)
[Link]('Departments')
[Link]('Salary')
[Link]('Department Wise Total Salary')
[Link]()
elif (chartchoice == 2):
dftemp = [Link] ('department').aggregate('sum')
depts = [Link].to_list()
salarysum = dftemp['salary']
[Link](depts,salarysum)
[Link]('Departments')
[Link]('Salary')
[Link]('Department Wise Total Salary')
[Link]()
elif (chartchoice == 3):
dftemp = [Link] ('department').aggregate('mean')
depts = [Link].to_list()
salarysum = dftemp['salary']
[Link](depts,salarysum)
[Link]('Departments')
[Link]('Salary')
[Link]('Department Wise Average Salary')
[Link]()