ai-lover commited on
Commit
745810e
·
verified ·
1 Parent(s): a71ffdd

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -0
app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import streamlit as st
3
+ import pandas as pd
4
+ import numpy as np
5
+
6
+ def load_data(file):
7
+ try:
8
+ df = pd.read_csv(file)
9
+ return df
10
+ except Exception as e:
11
+ st.error(f"Error loading file: {e}")
12
+ return None
13
+
14
+ def generate_summary(df):
15
+ summary = {
16
+ 'Column': df.columns,
17
+ 'Data Type': [str(df[col].dtype) for col in df.columns],
18
+ 'Non-Null Count': df.notnull().sum().values,
19
+ 'Unique Values': [df[col].nunique() for col in df.columns],
20
+ 'Sample Value': [df[col].iloc[0] if len(df[col]) > 0 else None for col in df.columns]
21
+ }
22
+ return pd.DataFrame(summary)
23
+
24
+ def generate_insights(df):
25
+ insights = []
26
+
27
+ # Example insights
28
+ if 'avg_training_score' in df.columns:
29
+ avg_score = df['avg_training_score'].mean()
30
+ insights.append(f"The average training score is {avg_score:.2f}. Consider additional training for employees below this score.")
31
+
32
+ if 'length_of_service' in df.columns:
33
+ experienced_employees = len(df[df['length_of_service'] > 5])
34
+ insights.append(f"{experienced_employees} employees have more than 5 years of service. Consider them for leadership roles.")
35
+
36
+ if 'awards_won' in df.columns:
37
+ award_winners = df['awards_won'].sum()
38
+ insights.append(f"A total of {award_winners} awards have been won by employees.")
39
+
40
+ return insights
41
+
42
+ # Streamlit app
43
+ st.title("Employee Performance Dashboard")
44
+ st.markdown("Upload your cleaned dataset to generate insights and suggestions.")
45
+
46
+ # File upload
47
+ uploaded_file = st.file_uploader("Upload CSV File", type="csv")
48
+
49
+ if uploaded_file is not None:
50
+ df = load_data(uploaded_file)
51
+
52
+ if df is not None:
53
+ st.markdown("### Dataset Preview")
54
+ st.dataframe(df.head())
55
+
56
+ st.markdown("### Dataset Summary")
57
+ summary = generate_summary(df)
58
+ st.dataframe(summary)
59
+
60
+ st.markdown("### Insights and Suggestions")
61
+ insights = generate_insights(df)
62
+ for insight in insights:
63
+ st.write(f"- {insight}")
64
+ else:
65
+ st.info("Please upload a CSV file.")