Calculating max value from selection

Hi guys,
I’m new to using Python and Streamlit and trying to figure out how to calculate to the max from a selection from a dropdown menu.

Expected behavior:

I have a dataframe with different column names. In the dropdown menu, all the column names show up as expected. From the selection, the idea is that the max value is found from the column(column consists of numbers, beside the column name). I later want to graph it but need to figure out this piece first.

Code snippet:

df=pd.read_csv('test.csv', parse_dates=["Date"])

sb_options = list(df.columns)

metric=st.selectbox('Select the Metric', options=sb_options)
calc_max = metric.max()

Actual behavior:

Right now it can’t find the max value because the app sees the selection as a string.

I appreciate all the help I can get, and let me know if I need to elaborate further.
Thanks!

That is probably because the columns are strings. What else do you expect them to be?

I expect them to be integers

You can convert them to integers. But then integers don’t have a .max() method either.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.