pypowsybl.network.Network.add_elements_properties#
- Network.add_elements_properties(df=None, **kwargs)[source]#
Add properties to network elements, provided as a
DataFrame
or as named arguments.- Parameters:
df (DataFrame | None) – the properties to be created or updated. The index has to be the id identifying the network elements.
kwargs (_SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) – the properties to be added as named arguments. Arguments can be a single string or any type of sequence of strings. In the case of sequences, all arguments must have the same length.
- Return type:
None
Examples
For example, to add the properties prop1 = value1 and prop2 = value2 to a network element:
>>> network.add_elements_properties(id='GENERATOR-1', prop1='value1', prop2='value2') >>> network.get_generators(attributes=['prop1', 'prop2'], id='GENERATOR-1') toto id VLEJUP7 tutu
You can also update multiple elements at once, for example with a dataframe:
>>> properties_df = pd.Dataframe(index=pd.Series('id', ['G1', 'G2']), data={ 'prop1': [ 'val11', 'val12'], 'prop2': [ 'val12', 'val22'], }) >>> network.add_elements_properties(properties_df) >>> network.get_generators(attributes=['prop1', 'prop2'], id=['G1', 'G2']) prop1 prop2 id G1 val11 val12 G2 val21 val22