elli-teu commited on
Commit
2bd6eac
·
1 Parent(s): effa819

UI partially works

Browse files
Files changed (2) hide show
  1. app.py +22 -3
  2. requirements.txt +2 -1
app.py CHANGED
@@ -6,6 +6,7 @@ import time
6
  import matplotlib.pyplot as plt
7
  import seaborn as sns
8
  from datetime import datetime, timedelta
 
9
 
10
  import api
11
 
@@ -160,12 +161,30 @@ def main():
160
  st.write(trip_ids[0])
161
 
162
  #Nu vill vi plotta!
 
 
 
 
 
 
163
  #Steg 2, fixa sa date ersätts av stop genom att mappa location till stop
164
  plot_df = st.session_state.data[st.session_state.data["trip_id"]==trip_ids[0]]
165
  plot_df = plot_df[["datetime", "vehicle_occupancystatus"]]
166
- plot_df = plot_df.set_index("datetime")
167
- st.line_chart(plot_df)
168
-
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
 
171
  else:
 
6
  import matplotlib.pyplot as plt
7
  import seaborn as sns
8
  from datetime import datetime, timedelta
9
+ import altair as alt
10
 
11
  import api
12
 
 
161
  st.write(trip_ids[0])
162
 
163
  #Nu vill vi plotta!
164
+ categories = {0 : 'EMPTY',
165
+ 1: 'MANY_SEATS_AVAILABLE',
166
+ 2:'FEW_SEATS_AVAILABLE',
167
+ 3:'STANDING_ROOM_ONLY',
168
+ 4:'CRUSHED_STANDING_ROOM_ONLY',
169
+ 5: 'FULL'}
170
  #Steg 2, fixa sa date ersätts av stop genom att mappa location till stop
171
  plot_df = st.session_state.data[st.session_state.data["trip_id"]==trip_ids[0]]
172
  plot_df = plot_df[["datetime", "vehicle_occupancystatus"]]
173
+ st.write(plot_df.head())
174
+ st.write(plot_df.tail())
175
+ #plot_df = plot_df.set_index("datetime")
176
+ plot_df["Y_category"] = plot_df["vehicle_occupancystatus"].map(categories)
177
+ #st.line_chart(plot_df)
178
+ # Create the Altair chart
179
+ chart = alt.Chart(plot_df).mark_line(point=True).encode(
180
+ x=alt.X('datetime:T', title="Datetime"), # Use column name as string
181
+ y=alt.Y('Y_category:N', title="Vehicle Occupancy Status (Categories)"), # Treat Y as categorical
182
+ tooltip=['datetime', 'Y_category'] # Add tooltips for interactivity
183
+ ).properties(
184
+ title="Vehicle Occupancy Status Over Time"
185
+ )
186
+ st.altair_chart(chart, use_container_width=True)
187
+
188
 
189
 
190
  else:
requirements.txt CHANGED
@@ -1,4 +1,5 @@
1
  twofish
2
  hopsworks
3
  matplotlib
4
- seaborn
 
 
1
  twofish
2
  hopsworks
3
  matplotlib
4
+ seaborn
5
+ altair