Spaces:
Sleeping
Sleeping
Update app.py
#2
by jfiel5 - opened
app.py
CHANGED
|
@@ -228,4 +228,27 @@ chart = alt.Chart(df_long).mark_bar(
|
|
| 228 |
height=400
|
| 229 |
)
|
| 230 |
|
| 231 |
-
st.altair_chart(chart, use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
height=400
|
| 229 |
)
|
| 230 |
|
| 231 |
+
st.altair_chart(chart, use_container_width=True)
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
#jacobs line chart salary over time
|
| 238 |
+
dfot=pd.read_csv('State_Employee_Pay_hired_after_1.1.2011_20251210.csv')
|
| 239 |
+
|
| 240 |
+
# Clean the salary column in case it has $ or commas
|
| 241 |
+
dfot['YTD Gross'] = df['YTD Gross'].replace('[\$,]', '', regex=True).astype(float)
|
| 242 |
+
|
| 243 |
+
# Compute average salary per agency division per year
|
| 244 |
+
avg_salary = dfot.groupby(['Year', 'Agency Division'], as_index=False)['YTD Gross'].mean()
|
| 245 |
+
|
| 246 |
+
# Create the line chart
|
| 247 |
+
lines = alt.Chart(avg_salary).mark_line(point=True).encode(
|
| 248 |
+
x=alt.X('Year:O', title='Year'), # treat Year as ordinal
|
| 249 |
+
y=alt.Y('YTD Gross:Q', title='Average Salary'),
|
| 250 |
+
color=alt.Color('Agency Division:N', title='Division'),
|
| 251 |
+
tooltip=['Year', 'Agency Division', 'YTD Gross']
|
| 252 |
+
).interactive() # enables zooming and panning
|
| 253 |
+
|
| 254 |
+
lines
|