From 912fb606c546f67ee036afca6712fd46a08e64f2 Mon Sep 17 00:00:00 2001 From: cdeline Date: Mon, 9 Sep 2024 11:46:12 -0600 Subject: [PATCH] Make sure to remove duplicate columns from results, which was causing errors.. --- bifacial_radiance/main.py | 5 +++-- bifacial_radiance/performance.py | 1 + tests/test_bifacial_radiance.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bifacial_radiance/main.py b/bifacial_radiance/main.py index 44708386..71dccf1c 100644 --- a/bifacial_radiance/main.py +++ b/bifacial_radiance/main.py @@ -4373,9 +4373,10 @@ def results(self): results = pd.DataFrame.from_dict(resultdict, orient='index').T.rename( columns={'modWanted':'modNum', 'rowWanted':'rowNum'}) if getattr(self, 'power_data', None) is not None: - return pd.concat([results, self.power_data], axis=1) + results = pd.concat([results, self.power_data], axis=1) + return results.loc[:,~results.columns.duplicated()] else: - return results + return results.loc[:,~results.columns.duplicated()] except AttributeError: return None diff --git a/bifacial_radiance/performance.py b/bifacial_radiance/performance.py index 1e35f57e..bfdeb491 100644 --- a/bifacial_radiance/performance.py +++ b/bifacial_radiance/performance.py @@ -247,6 +247,7 @@ def calculatePerformance(module, csvfile=None, results=None, dfst['sceneNum'] = data['sceneNum'] else: if results is not None: + results = results.loc[:,~results.columns.duplicated()] Wm2Front = pd.DataFrame.from_dict(dict(zip( results.index, results['Wm2Front']))).T Wm2Back = pd.DataFrame.from_dict(dict(zip( diff --git a/tests/test_bifacial_radiance.py b/tests/test_bifacial_radiance.py index 64c2b51d..a39f2bc3 100644 --- a/tests/test_bifacial_radiance.py +++ b/tests/test_bifacial_radiance.py @@ -269,6 +269,7 @@ def test_1axis_gencumSky(): index_col=0).iloc[:,0] module.addCEC(CECMod) results = demo.calculatePerformance1axis(module=module) + results = demo.calculatePerformance1axis(module=module) pd.testing.assert_frame_equal(results, demo.compiledResults) assert results.iloc[0].Grear_mean == pytest.approx(210, abs=30) #gencumsky has lots of variability assert results.__len__() == 4