From dac9299658c8286653a803195ab19440860091e8 Mon Sep 17 00:00:00 2001 From: Jonas Hoersch Date: Mon, 18 Jan 2016 16:58:32 +0100 Subject: [PATCH] opf: add a work around for pandas bug #12050 --- opf.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/opf.py b/opf.py index 9cf4c616a..08e588019 100644 --- a/opf.py +++ b/opf.py @@ -38,6 +38,7 @@ from .pf import calculate_dependent_values, find_slack_bus from itertools import chain +from distutils.version import StrictVersion import pandas as pd @@ -410,6 +411,9 @@ def define_linear_objective(network,snapshots): def extract_optimisation_results(network,snapshots): + if isinstance(snapshots, pd.DatetimeIndex) and StrictVersion(pd.version.version) < '0.18.0': + # Work around pandas bug #12050 (https://github.com/pydata/pandas/issues/12050) + snapshots = list(snapshots) #get value of objective function network.objective = network.results["Problem"][0]["Lower bound"]