Skip to content

Commit

Permalink
Merge pull request #144 from agoenergy/units_in_user_changes
Browse files Browse the repository at this point in the history
show units in user changes and rename columns
  • Loading branch information
markushal authored Nov 28, 2023
2 parents 8bed9d8 + 7f4277f commit a11ed5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
16 changes: 14 additions & 2 deletions app/ptxboa_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 2 additions & 5 deletions ptxboa_streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

logger.info("Updating app...")


# app layout:

# Set the pandas display option to format floats with 2 decimal places
Expand All @@ -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)


(
Expand All @@ -82,9 +82,6 @@
]
)


api = st.cache_resource(PtxboaAPI)()

# create sidebar:
make_sidebar(api)

Expand Down

0 comments on commit a11ed5f

Please sign in to comment.