hey assistent I have this if st.sessionstate.atselected: criteriadict = pd.DataFrame( {…
- User
hey assistent I have this if st.session_state.at_selected: criteria_dict = pd.DataFrame( { "Time_detections [s]": Time_detections, "Gmax [m/s²]": Gmax, "G0-4kph [m/s²]": G0_4kph, "G4-40kph [m/s²]": G_4_40kph, "Gmax-0-4kph [m/s²]": G_Max_0_4kph, "G-Vmax [m/s²]": G_Vmax, "Vmoy4-40 [kph]": V_4_40kph, "G0-10 [m/s²]": G0_10, "Vmax [kph]": Vmax, "G08": G08, } ) elif st.session_state.mt_selected: criteria_dict = pd.DataFrame( { "Time_detections [s]": Time_detections, "Gmax [m/s²]": Gmax, "G0-4kph [m/s²]": G0_4kph, "G4-40kph [m/s²]": G_4_40kph, "Gmax-0-4kph [m/s²]": G_Max_0_4kph, "G-Vmax [m/s²]": G_Vmax, "Vmoy4-40 [kph]": V_4_40kph, "G0-10 [m/s²]": G0_10, "Vmax [kph]": Vmax, "G08": G08, "Clutch synchro [sec]": clutch_synchro, "Clutch pedal duration [sec]": clutch_pedal_duration_sec, "G @ clutch synchro [m/s^2]": G_clutch_synchro_ms2, } ) styled_df = criteria_dict.style.apply(color_all_columns_based_on_A, axis=1)
code# criteria_dict_ = criteria_dict.style.applymap(color_negative_red, subset=pd.IndexSlice[:, ['Vmax [kph]']]) st.write(p1, p2) st.header("Table of criteria") st.dataframe(styled_df) st.markdown( get_table_download_link( criteria_dict, "Table of criteria", ":floppy_disk: Table of criteria_CSV", ), unsafe_allow_html=True, )I want to add if mt_selected to style_df another criteria. That criteria I don't wnat in the criteria dict, just in styled df
- Assistant
- User
if st.session_state.mt_selected: # Add extra column-based styling only for styled_df def highlight_clutch_synchro(row): """ Example styling rule for 'Clutch synchro [sec]'. If value exceeds a threshold, apply red background color. """ value = row.get("Clutch synchro [sec]", None) if value is not None and value > 2: # Example rule: highlight if > 2 seconds return ["background-color: red" if col == "Clutch synchro [sec]" else "" for col in row.index] else: return [""] * len(row)
codestyled_df = styled_df.apply(highlight_clutch_synchro, axis=1) ok no need to a function, I already have the crietria is called "wheel spin" with the value wheel spin. I want to add it just for mt and styled - Assistant
- User
yeah but this saved the criteria in criteria_dict, alteas remove it after
- Assistant