Briemcc commited on
Commit
fc49f6e
·
verified ·
1 Parent(s): a65b50e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -53
app.py CHANGED
@@ -17,59 +17,9 @@ st.text("The URL for this app is: https://huggingface.co/spaces/445final/final2.
17
 
18
 
19
 
20
- df = pd.read_csv('State_Employee_Pay.csv')
21
-
22
- df_copy = df.copy()
23
- df['Period Pay Rate'] = df['Period Pay Rate'].str.replace(",", "")
24
- df['YTD Gross'] = df['YTD Gross'].str.replace(",", "")
25
- df['Period Pay Rate'] = df['Period Pay Rate'].astype(int)
26
- df['YTD Gross'] = df['YTD Gross'].astype(int)
27
- df = df.dropna()
28
- df = df[df['YTD Gross']!= 0]
29
- df['Agency'] = df['Agency'].str.lower()
30
- df['Agency Division'] = df['Agency Division'].str.lower()
31
- df['Employee Name'] = df['Employee Name'].str.lower()
32
- df['Position Title'] = df['Position Title'].str.lower()
33
-
34
- df_c = df[df['Agency'] == 'corrections']
35
- df_t = df[df['Agency'] == 'transportation']
36
-
37
- df1 = df_t
38
-
39
- #agency_division_list = df1['Agency Division'].value_counts().tolist()
40
- agency_division_list = df1['Agency Division'].unique().tolist()
41
-
42
- selected_division = st.selectbox('Agency Division:',
43
- options=agency_division_list,
44
- index=0)
45
-
46
- # horizontal bar chart
47
-
48
- def division_positions(selected_division):
49
- df_db = df1[df1['Agency Division'] == selected_division]
50
-
51
- bar_chart_data = df_db.groupby('Position Title').agg(
52
- employeeCount=('Employee Name', 'count'),
53
- meanYTDGross=('YTD Gross', 'mean')).reset_index()
54
-
55
- bar_chart_data = bar_chart_data.sort_values('meanYTDGross', ascending=False)
56
-
57
- chart_bar = alt.Chart(bar_chart_data).mark_bar().encode(
58
- x=alt.X('employeeCount', title = '# of Employees'),
59
- y=alt.Y('Position Title:O',axis=alt.Axis(labelLimit=0, title='Position Title')),
60
- tooltip=['Position Title', 'employeeCount', alt.Tooltip(
61
- 'meanYTDGross:Q', format='$,.0f', title='Avg YTD Gross')]
62
- ).properties(title=f'Employee Count by Position in: {selected_division}',
63
- height=alt.Step(20)).interactive()
64
- return chart_bar
65
-
66
-
67
- if selected_division:
68
- final_chart = division_positions(selected_division)
69
- st.altair_chart(final_chart, use_container_width=True)
70
-
71
- st.text('Overall Future Edits: Figure out what to do with positions with 1 employee (if anything), Decide whether to use transportation or corrections data, Re-capitalize agency departments')
72
- st.text('Chart A Future Edits: Order bars by mean YTD Gross, Make all position titles readable, add title')
73
 
74
 
75
 
 
17
 
18
 
19
 
20
+
21
+ #st.text('Overall Future Edits: Figure out what to do with positions with 1 employee (if anything), Decide whether to use transportation or corrections data, Re-capitalize agency departments')
22
+ #st.text('Chart A Future Edits: Order bars by mean YTD Gross, Make all position titles readable, add title')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
 
25