Okay, so I’m new to streamlit and have not coded python in a while so this might be really obvious and I just don’t get it. Anyway, what I’m trying to do is build an app that displays a stress-strain curve. In the sidebar I want to be able to select and unselect specs and then have the graphs show up or not.
My data is saved in three variables. The first is a list that includes all the specs for which I want to filter. The second includes the strain data for all samples, and the third includes the stress data. Sample 1 is stored in each first column, sample 2 in each second and so on. Also, between the samples the lengths are not static, so sample 1 is longer than sample 2. Oh and at the moment the titles of the columns of stress and strain are only indices, I tried the command data.columns = [spec] but that didn’t really help me.
I have set up the sidebox, but I don’t really know how to connect the df_selection to my stress and strain curves. Also, can I use a for loop to generate the plot?
Hope that is somehow understandable. Thanks already for any input
Oh yeah, I know that the code works. I want to use the “Spec” as basis for a filter. And I don’t know how to connect the Spec to the data that I have in my two variables. And I was hoping for input in that regard.
Sorry if that was confusing.
Does this help to make sense of it? Each column of the stress variable and the strain variable is equal to one line of the spec variable.
I could also combine stress and strain in one variable, if that is necessary.
Well, not quite. In my df I have the spec, then the stress and the strain. Then I separate the values into unique variables. Through the .unique filtering, I get the specs in the list and through finding the start indices for the others, I have a DataFrame for stress and strain individually. As the variables are not of the same length, I thought this was the best way, cause later on I want to plot strain (xaxis) against stress (yaxis).
So I have the Mastervariable that includes the specs, stress and strain and then I separate them into the list spec, and the Dataframes Stress and Strain that each have a column for each spec.
Yes, df_selection does have all the data I need, in theory. But the structure of the data is not correct I think. If I plot the data in df_selection as it is now, I don’t get individual graphs for each spec but one giant mess. So I thought it was more efficient to separate the data into individual variables and then plot them. But as I said, I’m new to this, so this might not be the most efficient way to work. If you have a different suggestion, I’m happy for any input!
So I want to connect the first columns of the stress and strain data to the first line of the specs data. Then the second line to the second columns and so on. And I want to be able to filter for the specs and turn them off and on in the plot of stress and strain
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.