pypowsybl.network.Network.add_elements_properties¶
- Network.add_elements_properties(df=None, **kwargs)[source]¶
Add properties to network elements, provided as a
DataFrameor 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 (ArrayLike) – 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') prop1 prop2 id GENERATOR-1 value1 value2
You can also update multiple elements at once, for example with a dataframe:
>>> properties_df = pd.DataFrame.from_records(index='id', data={ 'id': ['G1', 'G2'], '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