From f8a6f82bbc05825b70edb2b5996c115a69c9c809 Mon Sep 17 00:00:00 2001 From: Justin Martinez Date: Wed, 4 Oct 2017 13:59:50 -0600 Subject: [PATCH 1/2] keep_max_form creates a copy df using MultiIndex to store sliced data from feasibility table. This happens when user passes list in forms parameter to pick() in developer --- urbansim/developer/developer.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/urbansim/developer/developer.py b/urbansim/developer/developer.py index 95cd5b2f..a2e3c24a 100644 --- a/urbansim/developer/developer.py +++ b/urbansim/developer/developer.py @@ -62,7 +62,13 @@ def keep_form_with_max_profit(self, forms=None): f = self.feasibility if forms is not None: - f = f[forms] + feas = pd.DataFrame(index=f.index, + columns=pd.MultiIndex.from_tuples(f[forms].columns.values)) + + for form in forms: + feas[form] = f[form].values + + f = feas if len(f) > 0: mu = self._max_form(f, "max_profit") From bc84eb3053d97a13b49334ee4462db93207dad80 Mon Sep 17 00:00:00 2001 From: Justin Martinez Date: Wed, 4 Oct 2017 14:13:45 -0600 Subject: [PATCH 2/2] keep_max_form creates a copy df using MultiIndex and remove_unused_levels() to get sliced data from feasibility table. --- urbansim/developer/developer.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/urbansim/developer/developer.py b/urbansim/developer/developer.py index a2e3c24a..db5a861f 100644 --- a/urbansim/developer/developer.py +++ b/urbansim/developer/developer.py @@ -62,13 +62,8 @@ def keep_form_with_max_profit(self, forms=None): f = self.feasibility if forms is not None: - feas = pd.DataFrame(index=f.index, - columns=pd.MultiIndex.from_tuples(f[forms].columns.values)) - - for form in forms: - feas[form] = f[form].values - - f = feas + f_index = f[forms].columns.remove_unused_levels() + f = pd.DataFrame(data=f[forms], columns=f_index) if len(f) > 0: mu = self._max_form(f, "max_profit")