n = len(chunk)
timeframe = timeframe.intersect(chunk_from_next_meter.timeframe)
chunk += chunk_from_next_meter
chunk = chunk.dropna()
if len(chunk) < n:
warn("Meters are not perfectly aligned.")
if chunk is None:
After Change
// Load each generator and yield the sum
while True:
chunk = pd.DataFrame()
columns_to_average_counter = pd.DataFrame()
timeframe = TimeFrame()
// Go through each generator to try sum values together
for generator in generators:
try:
chunk_from_next_meter = next(generator)
except StopIteration:
continue
timeframe = timeframe.intersect(chunk_from_next_meter.timeframe)
chunk = chunk.add(chunk_from_next_meter, fill_value=0, level="physical_quantity")
if len(chunk) != len(chunk_from_next_meter):
warn("Meters are not perfectly aligned.")
// Update columns_to_average_counter
physical_quantities = chunk_from_next_meter.columns.get_level_values("physical_quantity")
columns_to_average = (set(PHYSICAL_QUANTITIES_TO_AVERAGE)
.intersection(physical_quantities))
counter_increment = pd.DataFrame(1, columns=columns_to_average,
index=chunk_from_next_meter.index)
columns_to_average_counter = columns_to_average_counter.add(
counter_increment, fill_value=0)
if chunk.empty:
break
// Divide any columns which need dividing to create mean values