Skip to content

Commit

Permalink
fs.to_dataframe column order fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
elphick committed Nov 5, 2024
1 parent bfb4c47 commit 98a7bcd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions elphick/geomet/flowsheet/flowsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,9 @@ def to_dataframe(self, stream_names: Optional[list[str]] = None, tidy: bool = Tr

results: pd.DataFrame = pd.concat(chunks, axis='index').set_index('name', append=True)
if not tidy: # wide format
results = results.unstack(level='name').swaplevel(axis=1)
results.columns = [f'{col[0]}_{col[1]}' for col in results.columns]
results = results.unstack(level='name', sort=False)
results.columns = [f'{name}_{attr}' for name in results.columns.levels[1] for attr in
results.columns.levels[0]]

return results

Expand Down

0 comments on commit 98a7bcd

Please sign in to comment.