Skip to content

Commit

Permalink
Merge pull request #389 from ZJUEarthData/dev/Yongkang
Browse files Browse the repository at this point in the history
perf: Improved to add names to data
  • Loading branch information
SanyHe authored Sep 22, 2024
2 parents 0114435 + 3bb3fd3 commit 6f7b278
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion geochemistrypi/data_mining/utils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def save_data(df: pd.DataFrame, name_column: str, df_name: str, local_data_path:
Whether to write the index.
"""
if name_column is not None and len(df) == len(name_column):
name_column = name_column.loc[df.index].reset_index(drop=True)
if not df.index.empty and len(name_column.index) == len(df.index) and set(df.index) == set(name_column.index):
name_column = name_column.reindex(df.index)
df.reset_index(drop=True, inplace=True)
name_column.reset_index(drop=True, inplace=True)
df = pd.concat([name_column, df], axis=1)
Expand Down

0 comments on commit 6f7b278

Please sign in to comment.