How to have a dataframe with input

Hi i would like to create an app with this structure :

Name     weight   weight2  Risk_Contribution 
Val1         10%
Val2         10%
Val3         10%
Val4         70%

I would like :

  • To add eventualy a new Name
  • to input Weight 2 and from this to calculate a Risk_Contribution (use weight2 as input)

What is the best way to do that ?

Thanks

Hi @Jacques2101

Firstly, you can use:

  • st.text_input for accepting the Name string values
  • st.number_input or st.slider for accepting numerical values

Next, you can combine these user-provided information as a DataFrame via the pandas library.

Finally, to calculate the Risk_Contribution you may either have to build a machine learning model or have an equation from which to calculate this value. Finally the calculated value can be displayed in-app via st.write, st.info, st.warning, st.error`, etc.

Hope this helps!

This link has answer towards the end that might help you.
The answer from Constantine Kurbatov can help you.