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.
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