diff --git a/app/ptxboa_functions.py b/app/ptxboa_functions.py index e2682a8c..b1ba20ca 100644 --- a/app/ptxboa_functions.py +++ b/app/ptxboa_functions.py @@ -225,11 +225,23 @@ def reset_user_changes(): st.session_state["user_changes_df"] = None -def display_user_changes(): +def display_user_changes(api): """Display input data changes made by user.""" if st.session_state["user_changes_df"] is not None: + df = st.session_state["user_changes_df"].copy() + parameters = api.get_dimension("parameter") + df["Unit"] = df["parameter_code"].map( + pd.Series(parameters["unit"].tolist(), index=parameters["parameter_name"]) + ) st.dataframe( - st.session_state["user_changes_df"].style.format(precision=3), + df.rename( + columns={ + "source_region_code": "Source Region", + "process_code": "Process", + "parameter_code": "Parameter", + "value": "Value", + } + ).style.format(precision=3), hide_index=True, ) else: diff --git a/ptxboa_streamlit.py b/ptxboa_streamlit.py index 5d5e1e6f..c996d4c6 100644 --- a/ptxboa_streamlit.py +++ b/ptxboa_streamlit.py @@ -38,7 +38,6 @@ logger.info("Updating app...") - # app layout: # Set the pandas display option to format floats with 2 decimal places @@ -51,11 +50,12 @@ st.session_state["edit_input_data"] = False st.set_page_config(layout="wide") +api = st.cache_resource(PtxboaAPI)() st.title("PtX Business Opportunity Analyzer :red[draft version, please do not quote!]") if st.session_state["edit_input_data"]: st.warning("Data editing on") with st.expander("Modified data"): - pf.display_user_changes() + pf.display_user_changes(api) ( @@ -82,9 +82,6 @@ ] ) - -api = st.cache_resource(PtxboaAPI)() - # create sidebar: make_sidebar(api)