pypsa.Network.remove#
- Network.remove(class_name: str, name: str | int | Sequence[int | str], suffix: str = '') None#
Remove a single component or a list of components from the network.
Removes it from component DataFrames.
- Parameters:
Examples
>>> n = pypsa.Network() >>> n.snapshots = pd.date_range("2015-01-01", freq="h", periods=2) >>> n.add("Bus", ["bus0", "bus1"]) Index(['bus0', 'bus1'], dtype='object') >>> n.add("Bus", "bus2", p_min_pu=[1, 1]) Index(['bus2'], dtype='object', name='Bus') >>> n.components.buses.static v_nom type x y ... v_mag_pu_max control generator sub_network Bus ... bus0 1.0 0.0 0.0 ... inf PQ bus1 1.0 0.0 0.0 ... inf PQ bus2 1.0 0.0 0.0 ... inf PQ [3 rows x 13 columns]
Remove a single component: >>> n.remove(“Bus”, “bus2”)
Any component data is dropped from the component DataFrames. >>> n.components.buses.static
v_nom type x y … v_mag_pu_max control generator sub_network
Bus … bus0 1.0 0.0 0.0 … inf PQ bus1 1.0 0.0 0.0 … inf PQ <BLANKLINE> [2 rows x 13 columns] >>> n.components.buses.dynamic.p_min_pu Empty DataFrame Columns: [] Index: [2015-01-01 00:00:00, 2015-01-01 01:00:00]
Remove multiple components: >>> n.remove(“Bus”, [“bus0”, “bus1”])
>>> n.components.buses.static Empty DataFrame Columns: [v_nom, type, x, y, carrier, unit, location, v_mag_pu_set, v_mag_pu_min, v_mag_pu_max, control, generator, sub_network] Index: []