pypsa.Network.import_components_from_dataframe#
- Network.import_components_from_dataframe(dataframe: pd.DataFrame, cls_name: str) None #
Import components from a pandas DataFrame.
This function is deprecated. Use :py:meth`pypsa.Network.add` instead. To get the same behavior for importing components from a DataFrame, use n.add(cls_name, df.index, **df).
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'] >>> n.import_components_from_dataframe( ... pd.DataFrame({"v_nom" : 380, "control" : 'PV'}, ... index=buses), ... "Bus") >>> n.import_components_from_dataframe( ... pd.DataFrame({"carrier" : "solar", "bus" : buses, "p_nom_extendable" : True}, ... index=[b+" PV" for b in buses]), ... "Generator")
See also
Deprecated since version 0.29: This will be removed in 1.0. Use n.add instead. E.g. n.add(class_name, df.index, **df).