Hey Jack,
no worries, happy to help. Before trying to get down the pandas road, have tried out the LinearExpression.groupby_sum function? Ideally you only have to make sure that passed groups have a the correct dimension name. For example
from linopy import Model
import pandas as pd
m = Model()
index = pd.Index(range(10), name='my-dim')
groups = pd.Series([1,1,1,1,1,2,2,2,2,2], index=index)
x = m.add_variables(0, 10, coords=[index])
expr = 2 * x
expr = expr.groupby_sum(groups.to_xarray())
`index` and `groups` are pandas objects, and only have to be
converted to xarray when needed. The only thing important really
is that the dimensions have explicit names. Does that make things
easier with xarray?
As for the integer variables, it is on the todo-list :)
Best
Fabian
--
You received this message because you are subscribed to the Google Groups "pypsa" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pypsa+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/pypsa/805f72fa-2832-4e77-9ece-d589c89a86c6n%40googlegroups.com.
-- Fabian Hofmann Postdoctoral Researcher Institute of Energy Technology Technische Universität Berlin http://fabianhofmann.org/ Group website: https://tub-ensys.github.io/