Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Source

Code
import pandas as pd
import matplotlib.pyplot as plt

employee_data =
pd.DataFrame(columns=['EmployeeID',
'Name','Gender', 'Age', ' Basic Salary',
'Department'])
print("\nWelcome to EMPLOYEES MANAGEMENT
SYSTEM\n")
while True:
print("\nEmployee Management System
Menu:")
print("1. Add Employee")
print("2. Display Employee Data")
print("3. Plot Basic Salary Bar Chart")
print("4. Search Employee")
print("5. Update Employee Information")
print("6. Input your data and Save that Data to
File")
print("7. Count no. of employees in each
department")
print("8. Calculate and display Gross and Final
Salary")
print("9. Calculate Bonus of Employees")
print("10. Plot Gross and Final Salary Bar Chart")
print("11. Exit")

employee_data = pd.read_csv("E:\IIT JEE\IP


project\Employee Management System\emp.csv")
choice = input("Enter your choice (1-11): ")
if choice == '1':
employee_id = input("Enter Employee ID: ")
name = input("Enter Name: ")
gender = input("Enter Gender: ")
age = int(input("Enter Age: "))
salary = float(input("Enter Basic Salary: "))
department = input("Enter Department: ")

new_employee =
pd.DataFrame([[employee_id, name, gender, age,
salary, department]],
columns=['EmployeeID', 'Name','Gender',
'Age', 'Basic Salary', 'Department'])
employee_data = pd.concat([employee_data,
new_employee], ignore_index=True)
print("Employee added successfully!")
employee_data.to_csv("E:\IIT JEE\IP
project\Employee Management
System\emp2.csv", index=False)

elif choice == '2':


print("\nEmployee Data:\n")
employee_data = pd.read_csv("E:\IIT JEE\IP
project\Employee Management
System\emp2.csv")
print(employee_data)

elif choice == '3':


employee_data = pd.read_csv("E:\IIT JEE\IP
project\Employee Management
System\emp2.csv")
employee_data.plot(x='Name', y='Basic
Salary', kind='bar', legend=False)
plt.title('Basic Salary Bar Chart')
plt.xlabel('Employee Name')
plt.ylabel('Basic Salary')
plt.show()

elif choice == '4':


new_new_employee = pd.read_csv("E:\IIT
JEE\IP project\Employee Management
System\emp.csv")
search_column = 'EmployeeID'
employee_id = int(input("Enter Employee ID
to search: "))

result =
employee_data[employee_data[search_column]
== employee_id]
if not result.empty:
print("Employee Found:", result)
else:
print("Data not found in the specified
column.")
elif choice == '5':
employee_data = pd.read_csv("E:\IIT JEE\IP
project\Employee Management
System\emp2.csv")
to_update_value = int(input("Enter value to
update: "))
column_to_update = input("Enter the field to
update (Name/Salary/Department): ")
new_value = int(input("Enter the new value
for: "))
employee_data.loc[to_update_value,
column_to_update] = new_value
print(employee_data)

elif choice == '6':


employee_id = input("Enter Employee ID: ")
name = input("Enter Name: ")
gender = input("Enter Gender: ")
age = int(input("Enter Age: "))
salary = float(input("Enter Basic Salary: "))
department = input("Enter Department: ")

employee_data = pd.read_csv("E:\IIT JEE\IP


project\Employee Management
System\emp2.csv")
new_employee =
pd.DataFrame([[employee_id, name, gender, age,
salary, department]],
columns=['EmployeeID', 'Name','Gender',
'Age', 'Basic Salary', 'Department'])
new_new_data = pd.concat([employee_data,
new_employee], ignore_index=True)
file_name = input("Enter the file name to
save data (include extension, e.g., data.csv): ")
new_new_data.to_csv(file_name,
index=False)
print("Data saved to", file_name)

elif choice == '7':


csv_file = "E:\IIT JEE\IP project\Employee
Management System\emp3.csv"
def
get_employee_count_by_department(csv_file):
df = pd.read_csv(csv_file)
department_count =
df.groupby('Department').size().to_dict()
return department_count
department_count =
get_employee_count_by_department(csv_file)
for department, count in
department_count.items():
print( department, count, "employees")

elif choice == '8':


csv_file_path = "E:\IIT JEE\IP
project\Employee Management
System\Salary_emp.csv"
df = pd.read_csv(csv_file_path)
df['Gross Salary'] = df['Basic Salary'] +
df['HRA'] + df['DA'] + df['MA']
df['Final Salary'] = df['Gross Salary'] - df['TDS']
- df['EPF']
print("Employee Data with Gross and Final
Salaries:")
print(df[['EmployeeID', 'Gross Salary', 'Final
Salary']])
df.to_csv("E:\IIT JEE\IP project\Employee
Management System\Salary_emp1.csv",
index=False)

elif choice == '9':


csv_file_path = "E:\IIT JEE\IP
project\Employee Management
System\Salary_emp1.csv"
df = pd.read_csv(csv_file_path)
bonus_percentage = float(input("Enter Bonus
Percentage: "))
df["Bonus"] = ((bonus_percentage/100) *
df["Final Salary"])
print("Bonus for Employee ID: ")
print(df[["EmployeeID", "Bonus"]])

elif choice == '10':


csv_file_path = "E:\IIT JEE\IP
project\Employee Management
System\Salary_emp1.csv"
df = pd.read_csv(csv_file_path)
df[['EmployeeID', 'Gross Salary', 'Final
Salary']].plot(x='EmployeeID', kind='bar', rot=0)
plt.title('Gross and Final Salary Comparison')
plt.xlabel('Employee ID')
plt.ylabel('Salary')
plt.show()

elif choice == '11':


print("Exiting the Employee Management
System. Goodbye :)")
break

else:
print("Invalid choice. Please enter a number
between 1 and 8.")
OUTPUT
SCREENS

You might also like