Annikaijak commited on
Commit
9bf01a0
·
verified ·
1 Parent(s): b0c3606

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -11
app.py CHANGED
@@ -33,6 +33,13 @@ def fill_nan_with_zero(value):
33
  else:
34
  return value
35
 
 
 
 
 
 
 
 
36
  # Creating tabs for the different features of the application
37
  tab1,tab2 = st.tabs(['Parking place near Building', 'Parking place near Bikelane'])
38
 
@@ -113,28 +120,49 @@ with tab1:
113
  # Immediately rerun the application
114
  st.experimental_rerun()
115
 
116
- # Get current time in UTC + 2 hours
117
- now = datetime.now() + timedelta(hours=2) # Get current time
118
- yesterday = now - timedelta(days=1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
 
120
- df_specific_time_range = building_new[(building_new['time'] >= yesterday) & (building_new['time'] <= now)]
121
- data_to_normalize = df_specific_time_range[['x', 'y', 'z']]
122
 
123
  # Applying StandardScaler
124
- scaler = StandardScaler()
125
- normalized_data = scaler.fit_transform(data_to_normalize)
126
 
127
  # Adding normalized data back to the DataFrame
128
- df_specific_time_range[['x', 'y', 'z']] = normalized_data
129
 
130
  # Streamlit plotting
131
- st.title('Normalized values of x, y, z from yesterday to today')
132
 
133
  # Converting the time column to string for better readability in Streamlit plots
134
- df_specific_time_range['time'] = df_specific_time_range['time'].astype(str)
135
 
136
  # Plotting using Streamlit's line chart
137
- st.line_chart(df_specific_time_range.set_index('time')[['x', 'y', 'z']])
138
 
139
  with tab2:
140
 
 
33
  else:
34
  return value
35
 
36
+ # Getting current time and yesterday
37
+ now = datetime.now() + timedelta(hours=2)
38
+ yesterday = now - timedelta(days=1)
39
+
40
+ # Defining scaler
41
+ scaler = StandardScaler()
42
+
43
  # Creating tabs for the different features of the application
44
  tab1,tab2 = st.tabs(['Parking place near Building', 'Parking place near Bikelane'])
45
 
 
120
  # Immediately rerun the application
121
  st.experimental_rerun()
122
 
123
+ # Creating plot for latest magnetic field data for building
124
+ # Filtering building_new for specific time
125
+ building_mag_specific_time_range = building_new[(building_new['time'] >= yesterday) & (building_new['time'] <= now)]
126
+
127
+ # Defining magnetic field data to normalise
128
+ building_mag_to_normalize = building_mag_specific_time_range[['x', 'y', 'z']]
129
+
130
+ # Applying StandardScaler
131
+ normalized_building_mag = scaler.fit_transform(building_mag_to_normalize)
132
+
133
+ # Adding normalized data back to the DataFrame
134
+ building_mag_specific_time_range[['x', 'y', 'z']] = normalized_building_mag
135
+
136
+ # Streamlit plotting
137
+ st.subheader('Normalized values of magnetic field data from yesterday to today')
138
+
139
+ # Converting the time column to string for better readability in Streamlit plots
140
+ building_mag_specific_time_range['time'] = building_mag_specific_time_range['time'].astype(str)
141
+
142
+ # Plotting using Streamlit's line chart
143
+ st.line_chart(building_mag_specific_time_range.set_index('time')[['x', 'y', 'z']])
144
+
145
+ # Creating plot for latest radar data for building
146
+ # Filtering building_new for specific time
147
+ building_rad_specific_time_range = building_new[(building_new['time'] >= yesterday) & (building_new['time'] <= now)]
148
 
149
+ # Defining magnetic field data to normalise
150
+ building_rad_to_normalize = building_rad_specific_time_range[['radar_0', 'radar_1', 'radar_2', 'radar_3', 'radar_4', 'radar_5', 'radar_6', 'radar_7']]
151
 
152
  # Applying StandardScaler
153
+ normalized_building_rad = scaler.fit_transform(building_rad_to_normalize)
 
154
 
155
  # Adding normalized data back to the DataFrame
156
+ building_rad_specific_time_range[['radar_0', 'radar_1', 'radar_2', 'radar_3', 'radar_4', 'radar_5', 'radar_6', 'radar_7']] = normalized_building_rad
157
 
158
  # Streamlit plotting
159
+ st.subheader('Normalized values of radar data from yesterday to today')
160
 
161
  # Converting the time column to string for better readability in Streamlit plots
162
+ building_rad_specific_time_range['time'] = building_rad_specific_time_range['time'].astype(str)
163
 
164
  # Plotting using Streamlit's line chart
165
+ st.line_chart(building_rad_specific_time_range.set_index('time')[['radar_0', 'radar_1', 'radar_2', 'radar_3', 'radar_4', 'radar_5', 'radar_6', 'radar_7']])
166
 
167
  with tab2:
168