ProfessorLeVesseur
commited on
Commit
•
0918e3b
1
Parent(s):
745f815
Update app.py
Browse files
app.py
CHANGED
@@ -130,6 +130,30 @@ ENGAGED_STR = 'Engaged (Respect, Responsibility, Effort)'
|
|
130 |
PARTIALLY_ENGAGED_STR = 'Partially Engaged (about 50%)'
|
131 |
NOT_ENGAGED_STR = 'Not Engaged (less than 50%)'
|
132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
def main():
|
134 |
st.title("Intervention Program Analysis")
|
135 |
|
@@ -141,12 +165,8 @@ def main():
|
|
141 |
# Read the Excel file into a DataFrame
|
142 |
df = pd.read_excel(uploaded_file)
|
143 |
|
144 |
-
# Format
|
145 |
-
df
|
146 |
-
df['Timestamp'] = pd.to_datetime(df['Timestamp']).dt.strftime('%I:%M %p')
|
147 |
-
df['Session Start Time'] = pd.to_datetime(df['Session Start Time']).dt.strftime('%I:%M %p')
|
148 |
-
df['Session End Time'] = pd.to_datetime(df['Session End Time']).dt.strftime('%I:%M %p')
|
149 |
-
df = df[['Date of Session', 'Timestamp'] + [col for col in df.columns if col not in ['Date of Session', 'Timestamp']]]
|
150 |
|
151 |
# Replace student names with initials
|
152 |
df = replace_student_names_with_initials(df)
|
|
|
130 |
PARTIALLY_ENGAGED_STR = 'Partially Engaged (about 50%)'
|
131 |
NOT_ENGAGED_STR = 'Not Engaged (less than 50%)'
|
132 |
|
133 |
+
def safe_convert_to_datetime(series, format_str=None):
|
134 |
+
try:
|
135 |
+
# Attempt to convert to datetime, ignoring errors
|
136 |
+
converted = pd.to_datetime(series, errors='coerce')
|
137 |
+
if format_str:
|
138 |
+
# Format if a format string is provided
|
139 |
+
return converted.dt.strftime(format_str)
|
140 |
+
return converted
|
141 |
+
except Exception as e:
|
142 |
+
print(f"Error converting series to datetime: {e}")
|
143 |
+
return series
|
144 |
+
|
145 |
+
def format_session_data(df):
|
146 |
+
# Format "Date of Session" and "Timestamp" columns with safe conversion
|
147 |
+
df['Date of Session'] = safe_convert_to_datetime(df['Date of Session'], '%m/%d/%Y')
|
148 |
+
df['Timestamp'] = safe_convert_to_datetime(df['Timestamp'], '%I:%M %p')
|
149 |
+
df['Session Start Time'] = safe_convert_to_datetime(df['Session Start Time'], '%I:%M %p')
|
150 |
+
df['Session End Time'] = safe_convert_to_datetime(df['Session End Time'], '%I:%M %p')
|
151 |
+
|
152 |
+
# Reorder columns
|
153 |
+
df = df[['Date of Session', 'Timestamp'] + [col for col in df.columns if col not in ['Date of Session', 'Timestamp']]]
|
154 |
+
|
155 |
+
return df
|
156 |
+
|
157 |
def main():
|
158 |
st.title("Intervention Program Analysis")
|
159 |
|
|
|
165 |
# Read the Excel file into a DataFrame
|
166 |
df = pd.read_excel(uploaded_file)
|
167 |
|
168 |
+
# Format the session data
|
169 |
+
df = format_session_data(df)
|
|
|
|
|
|
|
|
|
170 |
|
171 |
# Replace student names with initials
|
172 |
df = replace_student_names_with_initials(df)
|