Data Import and Export#

PyPSA is intended to be data format agnostic, but given the reliance internally on pandas DataFrames, it is natural to use comma-separated-variable (CSV) files.

Import from folder of CSV files#

Create a folder with CSVs for each component type (e.g. generators.csv, storage_units.csv), then a CSV for each time-dependent variable (e.g. generators-p_max_pu.csv, loads-p_set.csv). Then run pypsa.Network.import_from_csv_folder()

Note

It is not necessary to add every single column, only those where values differ from the defaults listed in Components. All empty values/columns are filled with the defaults.

Export to folder of CSV files#

The network can be exported as a folder of csv files with pypsa.Network.export_to_csv_folder().

Adding and removing components one-by-one#

Networks can also be built step-by-step for each component by calling pypsa.Network.add(). Likewise, components can also be removed with pypsa.Network.remove().

Adding and removing multiple components#

Multiple components can be added by calling pypsa.Network.madd(). Multiple components can be removed by calling pypsa.Network.mremove().

Adding components using pandas DataFrames#

To add multiple components whose static attributes are given in a pandas DataFrame, use pypsa.Network.import_components_from_dataframe()

To import time-varying information use pypsa.Network.import_series_from_dataframe()

Export to netCDF#

netCDF files take up less space than CSV files and are faster to load.

netCDF is also preferred over HDF5 because netCDF is structured more cleanly, is easier to use from other programming languages, can limit float precision to save space and supports lazy loading.

To export network and components to a netCDF file run pypsa.Network.export_to_netcdf().

Import from netCDF#

To import network data from netCDF file run pypsa.Network.import_from_netcdf().

Export to HDF5#

Note

netCDF is preferred over HDF5 because netCDF is structured more cleanly, is easier to use from other programming languages, can limit float precision to save space and supports lazy loading.

To export network and components to an HDF store run pypsa.Network.export_to_hdf5().

Import from HDF5#

To import network data from HDF5 store at path run pypsa.Network.import_from_hdf5().

Import from Pypower#

PyPSA supports import from Pypower’s ppc dictionary/numpy.array format version 2, see pypsa.Network.import_from_pypower_ppc().

Import from Pandapower#

Warning

Importing from pandapower is still in beta; not all pandapower data is supported.

PyPSA supports import from pandapower using the function pypsa.Network.import_from_pandapower_net().