Employee Information System
Create employees information system with Python data app!
Data Input and Calculation
-
- Data Loading: The code starts by importing the necessary libraries, setting the Streamlit page layout to a wide format, and loading an existing CSV file (’employeedb.csv’) into a Pandas DataFrame (
df
). This CSV file likely contains employee data, which is stored and managed within the Streamlit app. - Employee Registration: Within the ‘Register Staff’ section, users can input various employee details. The form fields collect information such as the employee’s first name, last name, email, gender, job title, department, date of employment, job status, and registration date. These inputs are essential for creating new employee records in the database.
- New Employee Function: The code defines a function called
new_employee
, which takes the collected employee information as arguments and creates a dictionary representing a new employee record. This dictionary is then converted into a Pandas DataFrame, and this new record is concatenated with the existing employee database (df
) usingpd.concat
. - Data Validation and Storage: When users submit the registration form, their input data is validated, and if everything is in order, a new employee record is added to the DataFrame. The DataFrame is then saved back to the ’employeedb.csv’ file to persistently store the updated employee data.
- Data Loading: The code starts by importing the necessary libraries, setting the Streamlit page layout to a wide format, and loading an existing CSV file (’employeedb.csv’) into a Pandas DataFrame (
Data Presentation and Visualization
- User Interface: The Streamlit app offers a user-friendly interface for employees’ data management. Users can choose between the ‘Register Staff’ and ‘Staff Database’ sections using a sidebar selectbox.
- Employee Database Display: In the ‘Staff Database’ section, the entire employee database stored in the DataFrame (
df
) is presented as a tabular data display usingst.dataframe
. This allows users to view all employee records in a table format, providing a clear and organized presentation of the data.
Data Management and CSV Operations
- Employee Registration and Storage: The primary purpose of this Streamlit app is to facilitate employee data management. It enables users to input new employee information, which is then stored, managed, and displayed. The app handles the complexities of creating new records and ensuring data integrity.
- CSV File Operations: CSV files serve as a data store for employee records. The code reads data from ’employeedb.csv’ into a DataFrame and, after new registrations, updates the CSV file to reflect the changes. This demonstrates the importance of handling data storage and retrieval operations, particularly when working with external data files
In summary, the code addresses the following subtopics:
Data Input and Calculation:
- The code loads existing employee data from a CSV file into a Pandas DataFrame.
- User input is collected for new employee registrations, and data validation ensures accuracy.
- Calculations such as registration date are automatically generated for each employee.
Data Presentation and Visualization:
- The app offers an organized user interface with a sidebar selectbox for navigation.
- The entire employee database is displayed in an interactive table using
st.dataframe
.
Data Management and CSV Operations:
- Users can register new employees, and the app handles data storage and management.
- CSV file operations are demonstrated, including reading, updating, and maintaining data consistency with external CSV files