When I try running this code using pandapower to run the powerflow timeseries of a low-voltage system, I get the following error: None of [Int64Index([0, 1, 2], dtype='int64')] are in the [index].

I suppose the problem is due to the csv-files I insert. I have uploaded them according to the correct format and view. Thus first the index of the static generator/load (0, 1 and 2) and then the values of active and reactive power. But even when I add the right index of the static generator/load in the right column, I get this error and I don’t know how to solve this.

Can someone help me with this? The error occured in line 68.

import pandapower as pp
import pandas as pd
import pandapower.control as control
import pandapower.networks as nw
import pandapower.timeseries as timeseries
from pandapower.timeseries.data_sources.frame_data import DFData

#create network
net = pp.create_empty_network()
pp.create_bus(net, name='bus1', vn_kv=20, type='n')
pp.create_bus(net, name='bus2', vn_kv=0.4, type='n')
pp.create_bus(net, name='bus3', vn_kv=0.4, type='n')
pp.create_bus(net, name='bus4', vn_kv=0.4, type='n')
pp.create_bus(net, name='bus5', vn_kv=0.4, type='n')

pp.create_ext_grid(net, pp.get_element_index(net, "bus", 'bus1'), vm_pu=1, va_degree=0, name='External grid',
                   s_sc_max_mva=10000, rx_max=0.1, rx_min=0.1)

lv_lines = pd.read_csv('.../EigenVoorbeeld/lines.csv', sep=';', header=0, decimal=',')
for _, lv_line in lv_lines.iterrows():
    from_bus = pp.get_element_index(net, "bus", lv_line.from_bus)
    to_bus = pp.get_element_index(net, "bus", lv_line.to_bus)
    pp.create_line(net, from_bus, to_bus, length_km=lv_line.length, std_type=lv_line.std_type, name=lv_line.line_name)

lv_loads = pd.read_csv('.../EigenVoorbeeld/loads.csv', sep=';', header=0, decimal=',')
for _, load in lv_loads.iterrows():
    bus_idx = pp.get_element_index(net, "bus", load.bus)
    pp.create_load(net, bus_idx, p_mw=load.p, q_mvar=load.q, name=load.load_name)

lv_sgens = pd.read_csv('.../EigenVoorbeeld/sgens.csv', sep=';', header=0, decimal=',')
for _, sgen in lv_sgens.iterrows():
    bus_idx = pp.get_element_index(net, "bus", sgen.bus)
    pp.create_sgen(net, bus_idx, p_mw=sgen.p, q_mvar=sgen.q, type=sgen.type, name=sgen.sgen_name)

hv_bus = pp.get_element_index(net, "bus", "bus1")
lv_bus = pp.get_element_index(net, "bus","bus2")
pp.create_transformer_from_parameters(net, hv_bus, lv_bus, sn_mva=.63, vn_hv_kv=20, vn_lv_kv=0.4, vkr_percent=1.325, vk_percent=4, pfe_kw=0.95, i0_percent=0.2375, tap_side="hv", tap_neutral=0, tap_min=-2, tap_max=2, tap_step_percent=2.5, tp_pos=0, shift_degree=150, name='MV-LV-Trafo')

n_ts = 1439 #1440 min 1 

df = pd.read_csv(".../EigenVoorbeeld/sgens_timeseries.csv")
ds = DFData(df)
const_sgen = control.ConstControl(net, element='sgen', element_index=net.sgen.index,
                                  variable='p_mw', data_source=ds, profile_name=net.sgen.index)

df = pd.read_csv(".../EigenVoorbeeld/loads_timeseries.csv")
ds = DFData(df)
const_load = control.ConstControl(net, element='load', element_index=net.load.index,
                                  variable='p_mw', data_source=ds, profile_name=net.load.index)

df = pd.read_csv(".../EigenVoorbeeld/loads_reactive_timeseries.csv")
ds = DFData(df)
const_load1 = control.ConstControl(net, element='load', element_index=net.load.index,
                                  variable='q_mvar', data_source=ds, profile_name=net.load.index)

ow = timeseries.OutputWriter(net, output_path="./", output_file_type=".xlsx")

ow.log_variable('res_bus', 'vm_pu')
ow.log_variable('res_line', 'loading_percent')

timeseries.run_timeseries(net)

The file loads_timeseries for example looks like this:

            0         1         2
0     0.00025  0.000213  0.000260
1     0.00025  0.000213  0.000260
2     0.00025  0.000213  0.000260
3     0.00025  0.000213  0.000260
4     0.00025  0.000213  0.000260
      ...       ...       ...
1435  0.00025  0.000159  0.000147
1436  0.00025  0.000213  0.000147
1437  0.00025  0.000213  0.000147
1438  0.00025  0.000213  0.000147
1439  0.00025  0.000213  0.000147

[1440 rows x 3 columns]

More information about where the error occured:

runfile('C:/Users/Gebruiker/OneDrive/Documenten/Masterproef/Pandapower/EigenVoorbeeld/example.py', wdir='C:/Users/Gebruiker/OneDrive/Documenten/Masterproef/Pandapower/EigenVoorbeeld')
No time steps to calculate are specified. I'll check the datasource of the first controller for avaiable time steps
Progress: |--------------------------------------------------| 0.1% CompleteTraceback (most recent call last):

  File "C:\Users\Gebruiker\OneDrive\Documenten\Masterproef\Pandapower\EigenVoorbeeld\example.py", line 68, in <module>
    timeseries.run_timeseries(net)

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandapower\timeseries\run_time_series.py", line 346, in run_timeseries
    run_loop(net, ts_variables, **kwargs)

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandapower\timeseries\run_time_series.py", line 318, in run_loop
    run_time_step(net, time_step, ts_variables, run_control_fct, output_writer_fct, **kwargs)

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandapower\timeseries\run_time_series.py", line 117, in run_time_step
    control_time_step(ts_variables['controller_order'], time_step)

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandapower\timeseries\run_time_series.py", line 84, in control_time_step
    ctrl.time_step(net, time_step)

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandapower\control\controller\const_control.py", line 155, in time_step
    self.values = self.data_source.get_time_step_value(time_step=time,

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandapower\timeseries\data_sources\frame_data.py", line 49, in get_time_step_value
    res = self.df.loc[time_step, profile_name]

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandas\core\indexing.py", line 925, in __getitem__
    return self._getitem_tuple(key)

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandas\core\indexing.py", line 1100, in _getitem_tuple
    return self._getitem_lowerdim(tup)

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandas\core\indexing.py", line 862, in _getitem_lowerdim
    return getattr(section, self.name)[new_key]

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandas\core\indexing.py", line 931, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandas\core\indexing.py", line 1153, in _getitem_axis
    return self._getitem_iterable(key, axis=axis)

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandas\core\indexing.py", line 1093, in _getitem_iterable
    keyarr, indexer = self._get_listlike_indexer(key, axis)

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandas\core\indexing.py", line 1314, in _get_listlike_indexer
    self._validate_read_indexer(keyarr, indexer, axis)

  File "C:\Users\Gebruiker\anaconda3\lib\site-packages\pandas\core\indexing.py", line 1374, in _validate_read_indexer
    raise KeyError(f"None of [{key}] are in the [{axis_name}]")

KeyError: "None of [Int64Index([0, 1, 2], dtype='int64')] are in the [index]"
0

There are 0 best solutions below