Redirect dataframe table from selections from selectbox

I have a dataframe table of call and put options, I’ve added a selectbar for I can select the expiration dates but I am having trouble for it to show the data for selected date. Any help is very appreciated!

Hi @Always_Flow,

Thanks for posting!

Can you share the code you’ve written to implement this so far?

Caroline :balloon:

Untitled 2
i’m using yahoo_fin api to get data, above i’ve put the photo of line of code that is allowing me to see data and it works fine, just quite haven’t figured out how to match the selectbox expiration with the presentation of dataframe table.

I suppose that callData is dataframe with a column expiration_date.
so, try

st.dataframe( callData[callData['expiration_date']==option])


this is what the dataframe contains, i’ve attempted to use: st.dataframe(callData[callData[‘Contract Name’]==option])
but the result shows nothing on the table.
Also thank you so much for your assistance i’m still fairly new to coding as I started 2 months ago haha.

What are the options of the selectbox?
In your your first post, you were asking to filter by ‘expiration date’ but now you are filtering by ‘Contract Name’. Your options must fit with values of the selected column.

ahhh i see i also attempted what you recommended but it isn’t in the column… these are my options on the select box i have created


Untitled2
on the line of code I am showing above is the way i get the option chain data, will i have to change the options in my select box to be able to see different dated contracts?

Your selectbox options should be populated from the relevant column of the dataframe.

option = st.selectbox('Choose expiration date', callData['Last Trade Date'].unique())

st.dataframe( callData[callData['Last Trade Date']==option])

This should work according to what you have sent.