pypsa.Network.import_components_from_dataframe#
- Network.import_components_from_dataframe(dataframe, cls_name)#
Import components from a pandas DataFrame.
If columns are missing then defaults are used.
If extra columns are added, these are left in the resulting component dataframe.
- Parameters:
dataframe (pandas.DataFrame) – A DataFrame whose index is the names of the components and whose columns are the non-default attributes.
cls_name (string) – Name of class of component, e.g.
"Line", "Bus", "Generator", "StorageUnit"
Examples
>>> import pandas as pd >>> buses = ['Berlin', 'Frankfurt', 'Munich', 'Hamburg'] >>> network.import_components_from_dataframe( pd.DataFrame({"v_nom" : 380, "control" : 'PV'}, index=buses), "Bus") >>> network.import_components_from_dataframe( pd.DataFrame({"carrier" : "solar", "bus" : buses, "p_nom_extendable" : True}, index=[b+" PV" for b in buses]), "Generator")
See also
pypsa.Network.madd