Save and Load Networks

pandapower networks can be saved and loaded using the pickle library or with an excel file.

pickle painlessly stores all datatypes, which is why the network will be exactly the same after saving/loading a network with the pickle library.

Excel has the upside that it provides a human readable format. However since Excel only accepts table-type inputs, some data mangling is necessary to save and load pandapower network through excel. Even though the relevant information is conserved, the process is not as robust as saving networks with pickle.

Important

Always use the pickle format unless you need a human readable file as output!

pickle

pandapower.to_pickle(net, filename)

Saves a pandapower Network with the pickle library.

INPUT:

net (dict) - The pandapower format network

filename (string) - The absolute or relative path to the input file.

EXAMPLE:

>>> pp.to_pickle(net, os.path.join("C:", "example_folder", "example1.p"))  # absolute path
>>> pp.to_pickle(net, "example2.p")  # relative path
pandapower.from_pickle(filename, convert=True)

Load a pandapower format Network from pickle file

INPUT:
filename (string) - The absolute or relative path to the input file.
OUTPUT:
net (dict) - The pandapower format network

EXAMPLE:

>>> net1 = pp.from_pickle(os.path.join("C:", "example_folder", "example1.p")) #absolute path
>>> net2 = pp.from_pickle("example2.p") #relative path

Excel

pandapower.to_excel(net, filename, include_empty_tables=False, include_results=True)

Saves a pandapower Network to an excel file.

INPUT:

net (dict) - The pandapower format network

filename (string) - The absolute or relative path to the input file.

OPTIONAL:

include_empty_tables (bool, False) - empty element tables are saved as excel sheet

include_results (bool, True) - results are included in the excel sheet

EXAMPLE:

>>> pp.to_excel(net, os.path.join("C:", "example_folder", "example1.xlsx"))  # absolute path
>>> pp.to_excel(net, "example2.xlsx")  # relative path
pandapower.from_excel(filename, convert=True)

Load a pandapower network from an excel file

INPUT:
filename (string) - The absolute or relative path to the input file.
OUTPUT:

convert (bool) - use the convert format function to

net (dict) - The pandapower format network

EXAMPLE:

>>> net1 = pp.from_excel(os.path.join("C:", "example_folder", "example1.xlsx")) #absolute path
>>> net2 = pp.from_excel("example2.xlsx") #relative path

Json

pandapower.to_json(net, filename)

Saves a pandapower Network in JSON format. The index columns of all pandas DataFrames will be saved in ascending order. net elements which name begins with “_” (internal elements) will not be saved. Std types will also not be saved.

INPUT:

net (dict) - The pandapower format network

filename (string) - The absolute or relative path to the input file.

EXAMPLE:

>>> pp.to_pickle(net, "example.json")
pandapower.from_json(filename, convert=True)

Load a pandapower network from a JSON file. The index of the returned network is not necessarily in the same order as the original network. Index columns of all pandas DataFrames are sorted in ascending order.

INPUT:
filename (string) - The absolute or relative path to the input file.
OUTPUT:

convert (bool) - use the convert format function to

net (dict) - The pandapower format network

EXAMPLE:

>>> net = pp.from_json("example.json")