From 973d1b1a902c466c56fd5add0742e2425bcf1585 Mon Sep 17 00:00:00 2001 From: Luigi Pertoldi Date: Fri, 5 May 2023 15:22:51 +0200 Subject: [PATCH] [flow] bug fix in FileDB.from_disk() --- src/pygama/flow/file_db.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pygama/flow/file_db.py b/src/pygama/flow/file_db.py index 61e54c7f2..0209cfbe0 100644 --- a/src/pygama/flow/file_db.py +++ b/src/pygama/flow/file_db.py @@ -533,9 +533,11 @@ def from_disk(self, path: str | list[str]) -> None: # read in dataframe df = pd.read_hdf(p, key="dataframe") + # first iteration if _columns is None: _columns = columns _df = df + continue elif _columns != columns: log.debug("found inconsistent FileDB, trying to merge") # if columns are not the same, need to merge the two dataframes @@ -561,9 +563,9 @@ def _replace_idx(row, idx, new_idx, tier): args=(idx, new_idx, tier), axis=1, ) - else: - # if columns are the same, assume we can safely concat the dataframes - _df = pd.concat([_df, df], ignore_index=True, copy=False) + + # now we can safely concat the dataframes + _df = pd.concat([_df, df], ignore_index=True, copy=False) self.set_config(_cfg) self.df = _df