Skip to content

Commit d02aa3f

Browse files
author
Gerit Wagner
committed
prep: check ID unique after ensuring that ID exists
1 parent 3090b1b commit d02aa3f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bib_dedupe/prep.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ def __general_prep(records_df: pd.DataFrame) -> pd.DataFrame:
123123

124124
if ID not in records_df.columns:
125125
records_df.loc[:, ID] = range(1, len(records_df) + 1)
126+
if not records_df[ID].is_unique:
127+
raise ValueError("ID column in records_df must be unique.")
126128

127129
if ENTRYTYPE not in records_df.columns:
128130
records_df[ENTRYTYPE] = "article"
@@ -195,8 +197,6 @@ def prep(records_df: pd.DataFrame, *, cpu: int = -1) -> pd.DataFrame:
195197
Returns:
196198
The prepared records dataframe.
197199
"""
198-
if not records_df["ID"].is_unique:
199-
raise ValueError("ID column in records_df must be unique.")
200200

201201
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
202202
verbose_print.print(f"Loaded {records_df.shape[0]:,} records")

0 commit comments

Comments
 (0)