From 4aa478f17b27880070a3be3e4cd4f300bb4938f7 Mon Sep 17 00:00:00 2001 From: Miriam Date: Mon, 20 Jul 2020 00:54:20 +0000 Subject: [PATCH] Imposed order on pandas dataframe The Travis CI test on Python 3.5 kept reordering the dataframe so that the results wouldn't match. For that reason, I had to impose the order of the columns with a clunky process: -drop the column of surfaces from whatever location it's in -reinsert the column of surfaces where I want it to be --- openmc/mgxs/mgxs.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openmc/mgxs/mgxs.py b/openmc/mgxs/mgxs.py index fb72cc9fc4..80a8580734 100644 --- a/openmc/mgxs/mgxs.py +++ b/openmc/mgxs/mgxs.py @@ -6239,14 +6239,17 @@ class SurfaceMGXS(MGXS): df = df[df['group out'].isin(groups)] mesh_str = 'mesh {0}'.format(self.domain.id) + surfaces = df[(mesh_str,'surf')] + df.drop(columns=[(mesh_str,'surf')],inplace=True) + df.insert(len(self.domain.dimension),(mesh_str,'surf'),surfaces) if len(self.domain.dimension) == 1: df.sort_values(by=[(mesh_str, 'x'), (mesh_str, 'surf')] + columns, inplace=True) elif len(self.domain.dimension) == 2: - df.sort_values(by=[(mesh_str, 'x'), (mesh_str, 'y'), + df.sort_values(by=[(mesh_str, 'x'), (mesh_str, 'y'), (mesh_str, 'surf')] + columns, inplace=True) elif len(self.domain.dimension) == 3: - df.sort_values(by=[(mesh_str, 'x'), (mesh_str, 'y'), + df.sort_values(by=[(mesh_str, 'x'), (mesh_str, 'y'), (mesh_str, 'z'), (mesh_str, 'surf')] + columns, inplace=True) return df