Source Code55
Source Code55
CODE
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
while True:
username=input('enter username:')
password=input('\nenter password:')
if username=='empl' and password=='jnv':
print('\nWELCOME TO EMPLOYEE MANAGEMENT SYSTEM\n')
break
else:
print('invalid username or password')
while True:
print('\t\t*Employee Data Analysis Project*')
print('\n\t\t\t1. Data Analysis')
print('\n\t\t\t2. Data Visualisation')
print('\n\t\t\t3. Data Operations')
print('\n\t\t\t4. Exit \n')
if choice == 1:
while True:
print('\t*EMPLOYEE MANAGEMENT SYSTEM*\n')
print('*' * 50)
print('\n\t\t1. Show Employee Data')
print('\n\t\t2. Show Data Name-Wise')
print('\n\t\t3. Show First nth Records')
print('\n\t\t4. Show Last nth Records')
print('\n\t\t5. Display Employee With Highest Salary')
print('\n\t\t6. Display Employee With Lowest Salary')
print('\n\t\t7. For Exit The Programe\n\n')
inner_choice=int(input('Enter Your Choice[1-7]:'))
if inner_choice==1:
print('\nEmployee Data:\n\n')
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
print(df)
elif inner_choice==2:
print('\nEmployee Data Name - Wise:\n\n')
df=pd.read_csv('C:\\Users\\User\\Desktop\\
employee.csv',usecols=['EMPLOYEEID','EMPLOYEENAME','PHONENO','SALARY',
'DEPARTMENT','GENDER','YEAROFJOIN'])
df=df.sort_values(by='EMPLOYEENAME')
print(df)
elif inner_choice==3:
print('\nFirst N Rows \n\n')
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
df=df.sort_values(by='EMPLOYEEID')
nth= int(input('How many rows to display? :'))
print(df.head(nth))
elif inner_choice==4:
print('\nLast n Rows\n\n')
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
df=df.sort_values(by='EMPLOYEEID')
nth=int(input('how many rows to display?:'))
print(df.tail(nth))
elif inner_choice==5:
elif inner_choice==6:
print('\nDisplay employee with lowest salary:\n\n')
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
df=df.sort_values(by='SALARY')
print(df.head(1))
elif inner_choice==7:
print('Exit to menu. ')
break
else:
print('invalid choice,Retry ')
elif choice==2:
while True:
print('Data visualisation')
print('\n\t1. Plot line chart(Name and basic salary)')
print('\n\t2. Plot bar chart vertical(Name and basic salary)')
print('\n\t3. Plot bar horizontal chart (Name and basic salary)')
print('\n\t4. Plot histogram(Basic salary)')
print('\n\t5. Exit\n')
choice=int(input('select your choice [1-5] :'))
if choice==1:
print('Line Chart')
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
df['EMPLOYEENAME']=['MANO M','RAHUL SOREN','ATHUL KRISHNA
MP','NAVEEN K S','ANGEL VINOD',
'AROMAL KK','ABHIRAM T ABHILASH','ASWATHY
AB','ABHINAV ABHILASH','ABHINAND J']
name=df['EMPLOYEENAME']
salary=df['SALARY']
plt.figure(figsize=(15,7))
plt.ylabel('SALARY-------->')
plt.xlabel('EMPLOYEENAME------->')
plt.title('### EMPLOYEENAME and SALARY ###')
plt.plot(name,salary,color='gold')
plt.grid()
plt.savefig('emp_line.pdf')
plt.show()
elif choice==2:
print('Bar chart')
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
df['EMPLOYEENAME']=['MANO M','RAHUL SOREN','ATHUL KRISHNA
MP','NAVEEN K S','ANGEL VINOD',
'AROMAL KK','ABHIRAM T ABHILASH','ASWATHY
AB','ABHINAV ABHILASH','ABHINAND J']
name=df['EMPLOYEENAME']
salary=df['SALARY']
plt.figure(figsize=(15,7))
plt.ylabel('SALARY')
plt.title('### NAME and SALARY ###')
plt.bar(name,salary,color='k')
plt.grid()
plt.savefig('emp_bar.jpg')
plt.show()
elif choice==3:
print('horizontal bar chart')
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
df['employeename']=['MANO M','RAHUL SOREN','ATHUL KRISHNA
MP','NAVEEN K S','ANGEL VINOD',
'AROMAL KK','ABHIRAM T ABHILASH','ASWATHY
AB','ABHINAV ABHILASH','ABHINAND J']
name=df['EMPLOYEENAME']
salary=df['SALARY']
plt.figure(figsize=(15,7))
plt.xlabel('salary')
plt.title('NAME and SALARY')
plt.barh(name,salary,color='r')
plt.grid()
plt.savefig('emp_barh.pdf')
plt.show()
elif choice==4:
print('histogram')
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
df['EMPLOYEENAME']=['MANO M','RAHUL SOREN','ATHUL KRISHNA
MP','NAVEEN K S','ANGEL VINOD',
'AROMAL KK','ABHIRAM T ABHILASH','ASWATHY
AB','ABHINAV ABHILASH','ABHINAND J']
name=df['EMPLOYEENAME']
salary=df['SALARY']
plt.figure(figsize=(15,7))
plt.title('EMPLOYEE SALARY DISTRIBUTION')
plt.hist(salary,bins=[45000,50000,55000,60000,65000,70000,75000,80000],col
or='r',edgecolor='black',linewidth=5)
plt.grid()
plt.savefig('emp_hist.pdf')
plt.show()
elif choice==5:
print('Exit To Main Menu........')
break
else:
print('Invalid Choice')
elif choice==3:
while True:
print('\nData Operations')
print('\n\t1. Add a row to DataFrame')
print('\n\t2. Remove a row from DataFrame')
print('\n\t3. Add a column to DataFrame')
print('\n\t4. Remove a column from DataFrame')
print('\n\t5. Exit\n')
choice = int(input('Select your choice [1-5]: '))
if choice==1:
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
EMPNO = int(input('EMPLOYEEID: '))
NAME = input('EMPLOYEENAME: ')
PHNO = int(input('Enter PHONENO: '))
SAL = int(input('Enter SALARY: '))
DEPT = input('Enter DEPARTMENT: ')
GENDER = input('GENDER[M/F/T]: ')
YOJ = int(input('Enter YEAR OF JOIN: '))
cr=df.shape[0]
df1=
pd.DataFrame({'EMPLOYEEID':EMPNO,'EMPLOYEENAME':NAME,'PHONENO':P
HNO,'SALARY':SAL
,'DEPARTMENT':DEPT,'GENDER':GENDER,'YEAROFJOIN':YOJ}
,index=[cr])
df=pd.concat([df,df1],ignore_index=True)
print(df.to_string(index=False))
print('Record added successfully.')
elif choice== 2:
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
print(df.to_string(index=False))
r=int(input('enter the employeeid to be removed:'))
df=df[df['EMPLOYEEID']!=r]
print(df.to_string(index=False))
print('record deleted successfully..')
elif choice==3:
print('add a column')
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
print(df)
AGE=[]
x=input('Enter Column Name:\t')
for i in range(len(df)):
age = int(input(f'Enter row data {i+1}:\t'))
AGE.append(age)
df['AGE']=AGE
print(x)
print('column added successfully..')
elif choice==4:
print('remove a column')
df=pd.read_csv('C:\\Users\\User\\Desktop\\employee.csv')
print(df)
c=input('enter columnname to be removed : ')
df=df.drop(c,axis=1)
print('column removed..')
elif choice==5:
print('exit to main menu..')
break
else:
print('invalid choice')
elif choice==4:
print('exit..')
break
else:
print('invalid choice')
OUTPUT
SCREEN