diff --git a/src/brainreg/utils/misc.py b/src/brainreg/utils/misc.py index ef3efdd..b967766 100644 --- a/src/brainreg/utils/misc.py +++ b/src/brainreg/utils/misc.py @@ -49,4 +49,4 @@ def safe_pandas_concat(df1: pd.DataFrame, df2: pd.DataFrame) -> pd.DataFrame: elif df1.empty and df2.empty: return pd.DataFrame(columns=df1.columns) else: - return pd.concat([df1, df2]) + return pd.concat([df1, df2], ignore_index=True) diff --git a/src/brainreg/utils/volume.py b/src/brainreg/utils/volume.py index 3409286..6dbed1a 100644 --- a/src/brainreg/utils/volume.py +++ b/src/brainreg/utils/volume.py @@ -12,6 +12,8 @@ import pandas as pd from brainglobe_utils.pandas.misc import initialise_df +from .misc import safe_pandas_concat + class UnknownAtlasValue(Exception): pass @@ -100,7 +102,7 @@ def add_structure_volume_to_df( "total_volume_mm3": [left_volume + right_volume], } ) - df = pd.concat([df, df_new_row], ignore_index=True) + df = safe_pandas_concat(df, df_new_row) return df