ValueError: cannot join with no overlapping index names
AnsweredI am trying to minimize:
sum (Xij * Cij )
sum (flow from node i to node j * transportation cost from node i to node j)
X is a gurobi.var object
in: type(x)
out: pandas.core.series.Series
in: x
out:
i j
CAL CAL <gurobi.Var x[CAL,CAL]>
CAR <gurobi.Var x[CAL,CAR]>
CENT <gurobi.Var x[CAL,CENT]>
FLA <gurobi.Var x[CAL,FLA]>
MIDA <gurobi.Var x[CAL,MIDA]>
...
TEX NY <gurobi.Var x[TEX,NY]>
SE <gurobi.Var x[TEX,SE]>
SW <gurobi.Var x[TEX,SW]>
TEN <gurobi.Var x[TEX,TEN]>
TEX <gurobi.Var x[TEX,TEX]>
c is in a Pandas DataFrame because when I used c.stack() to convert it into a series it was not letting me process it or multiply it with x either
in: type(c)
out:pandas.core.frame.DataFrame
in: c
out:
Cost $/MWh  

i  j  
CAL  CAL  0.000000 
CAR  87.773848  
CENT  46.406115  
FLA  96.928160  
MIDA  88.485428  
...  ...  ... 
TEX  NY  62.685476 
SE  28.679621  
SW  31.323380  
TEN  31.253810  
TEX  0.000000 
I am working with Pandas MultiIndex (followed the gurobipypandas webinar recommended path for modeling)
When I check if both x and c have the same index it says that they DO have the same index
in: x.index == c.index
out: array([ True, True, ... , True, True]) # 169 True values
But when I want to define the multiplication gives me the ValueError: cannot join with no overlapping index names
in: x * c
out: ValueError: cannot join with no overlapping index names
How can I fix this?
Thanks!
0

Already managed to solve it!!
in: x * c['Cost $/MWh']
out:
i j
CAL CAL 0.0 x[CAL,CAL]
CAR 87.77384785166932 x[CAL,CAR]
CENT 46.406115430596955 x[CAL,CENT]
FLA 96.92815957953998 x[CAL,FLA]
MIDA 88.48542831091272 x[CAL,MIDA]
...
TEX NY 62.68547569529123 x[TEX,NY]
SE 28.679621289877527 x[TEX,SE]
SW 31.32338030560834 x[TEX,SW]
TEN 31.253810487553967 x[TEX,TEN]
TEX 0.0 x[TEX,TEX]1
Please sign in to leave a comment.
Comments
1 comment