Skip to content

Commit

Permalink
Use safe concat of dataframes
Browse files Browse the repository at this point in the history
  • Loading branch information
willGraham01 committed Oct 26, 2023
1 parent 06fa8fa commit 2939283
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/brainreg/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion src/brainreg/utils/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 2939283

Please sign in to comment.