I would like to display all the results of Pyomo variables in a pandas dataframe. I had a look at this question Pyomo: Looping Over A Variable Method and tried to adjust it to my case without success. I always get error messages. Here is a part of my code:
model.set_timeslots = pyo.RangeSet(1, 288)
iterables = list (range (1, 288))
...
...
...
for v in model.component_objects(pyo.Var, active=True):
for index in v:
print(index, ': ', pyo.value(v[index]))
DF = pd.DataFrame(index=iterables)
for v in model.component_objects(pyo.Var, active=True):
for index in v:
DF.at[index, 'val'] = pyo.value(v[index])
So I would like to print each value of the variables for all 288 set values for the set model.set_timeslots. Further, I also have some variables that do not depend on a set (for example objective variables). I would also like them to be displayed in a pandas dataframe. Do you know how I can do that? I'd appreciate every comment and would be quite thankful for your help.
Reminder: Does nobody have an idea how I can do that?