pandapower
pandapower is an easy-to-use open-source tool for power system modeling, analysis, and optimization, designed for high automation. As of version 3.4.0, it integrates with pandas for data handling and various solvers for power flow calculations, supporting steady-state analysis, optimal power flow, state estimation, and short-circuit calculations. It maintains a regular release cadence with several updates per year.
Common errors
-
Power flow did not converge!
cause Various reasons, including network disconnections, invalid input data (e.g., zero impedance branches), missing external grids, or overloaded components.fixUse the built-in diagnostic function: `from pandapower.diagnostic import diagnostic; diagnostic(net)` to identify common issues. Check for zero impedance branches, ensure an external grid exists, and verify component parameters. -
AttributeError: 'pandapowerNet' object has no attribute 'bus_geodata'
cause Attempting to access old geo data tables (`net.bus_geodata` or `net.line_geodata`) in pandapower versions >=3.0.0 where the geo data structure has changed.fixAccess geographical data through the `geo` column in the respective element dataframes (e.g., `net.bus.geo`, `net.line.geo`), which now stores geojson strings. -
ImportError: cannot import name 'csc_matrix' from 'scipy.sparse'
cause This error can occur with newer NumPy/SciPy versions due to changes in internal SciPy namespaces, particularly around version 3.4.0 where `scipy.sparse.csc` and `scipy.sparse.csr` were adjusted.fixUpdate pandapower to the latest version (3.4.0 or newer) which includes fixes for these namespace changes. Ensure compatible SciPy and NumPy versions are installed as per pandapower's requirements. -
KeyError: 'mapbox' in plotly plotting or map doesn't render
cause This typically occurs in pandapower versions >=3.2.0 due to the transition of Plotly plotting from Mapbox to MapLibre. Old 'mapbox' related parameters are no longer recognized.fixUpdate your plotting calls to use MapLibre-compatible parameters. This includes changing `mapbox_style` to `map_style` and using trace names ending in `_map` instead of `_mapbox`.
Warnings
- breaking Plotly plotting functions in pandapower versions >=3.2.0 migrated from Mapbox to MapLibre. This changes internal Plotly trace names (e.g., `scatter_mapbox` to `scatter_map`) and layout properties (`layout.mapbox` to `layout.map`).
- breaking In pandapower versions >=3.2.0, the result parameters for three-phase transformers and lines were fixed for consistency. Specifically, `p_a_l_mw` was renamed to `pl_a_mw` (and similar for other phases and `ql` values).
- breaking pandapower 3.0.0 introduced significant changes to geo data storage, moving from dedicated tables (`net.bus_geodata`, `net.line_geodata`) to `geojson` strings stored directly in the element tables (`net.bus.geo`, `net.line.geo`). Additionally, controller and group parameters were renamed for consistency.
- gotcha Using SciPy versions incompatible with your Python version can cause installation failures or runtime issues. Specifically, Python 3.10 and pandapower versions around 3.3.x might require `scipy < 1.16`.
- gotcha Branches (lines, transformers) with zero impedance (e.g., `length_km = 0` for lines or `vk_percent=0` for transformers) will lead to non-converging power flow calculations due to infinite admittances.
Install
-
pip install pandapower -
pip install pandapower[all]
Imports
- pandapower
import pandapower as pp
- pandapower.networks
from pandapower import networks
import pandapower.networks as nw
- pandapower.plotting
import pandapower.plotting as plot
- pandapower.diagnostic.diagnostic
from pandapower.diagnostic import diagnostic
Quickstart
import pandapower as pp
# Create an empty network
net = pp.create_empty_network()
# Create buses
b1 = pp.create_bus(net, vn_kv=20., name="Bus 1")
b2 = pp.create_bus(net, vn_kv=0.4, name="Bus 2")
b3 = pp.create_bus(net, vn_kv=0.4, name="Bus 3")
# Create external grid (slack bus)
pp.create_ext_grid(net, bus=b1, vm_pu=1.02, name="Grid Connection")
# Create load
pp.create_load(net, bus=b3, p_kw=100, q_kvar=50, name="Load")
# Create transformer (using standard type)
pp.create_transformer_from_parameters(net, sn_kva=400., hv_bus=b1, lv_bus=b2,
vn_hv_kv=20., vn_lv_kv=0.4, vsc_percent=6.,
vscr_percent=1.425, i0_percent=0.3375,
pfe_kw=1.35, name="Trafo")
# Create a line
pp.create_line(net, from_bus=b2, to_bus=b3, length_km=0.1, std_type="NAYY 4x50 SE")
# Run power flow
pp.runpp(net)
# Print results
print("Bus Voltage Magnitude (p.u.):\n", net.res_bus.vm_pu)
print("Line Loading (%):\n", net.res_line.loading_percent)