Pandas DataFrame as input in Pyomo AbstractModel

121 views
Skip to first unread message

Hedda Gardian

unread,
Jul 25, 2017, 1:21:08 PM7/25/17
to Pyomo Forum
Hello,

im rather new to Pyomo and was trying to chance the usual .dat input foramt to a Pandas Data Frame or anything that is easier to handle.
Do you have any advice on how to insert a DataFrame into the model?

Thanks in advance for any advice.

David Woodruff

unread,
Jul 26, 2017, 1:11:01 PM7/26/17
to pyomo...@googlegroups.com
As soon as you say "DataFrame" you are talking about a python object so there is no direct analog to a dat file. If you had said "csv file" then I would have told you to look at the import data command. If you want to use a DataFrame (or more than one), you have lots of flexibility concerning how to do that in both concrete and abstract models. For an abstract model, you could use a BuildAction, for example.
   Dave


--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Akmal N

unread,
Sep 10, 2018, 3:26:20 AM9/10/18
to Pyomo Forum
Hi Hedda Gardian,

I am also interested to use Pandas in Pyomo to convert the problem solution into excel or notepad to read the results easily. If you have got any answer, could you please  share it with me?

Akmal 

Ties van der Heijden

unread,
Sep 10, 2018, 5:37:40 AM9/10/18
to Pyomo Forum
Hey Hedda,

I convert the DataFrame to a dictionary.
Just use the .to_dict() command.
dict = DF.to_dict()

Pyomo will be able to read it this way

Op dinsdag 25 juli 2017 19:21:08 UTC+2 schreef Hedda Gardian:
Reply all
Reply to author
Forward
0 new messages