Skip to content

Commit ec2ef67

Browse files
committed
Handle int when unexpectedly included in the lables e.g. CD07 has 0 in the label see HEA-751
1 parent bbe7a34 commit ec2ef67

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

pipelines/utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,14 @@ def prepare_lookup(data: str | list[str] | pd.Series | pd.DataFrame) -> pd.Serie
9393
elif isinstance(data, (list, pd.Series)):
9494
result = pd.DataFrame(data)
9595
else:
96-
result = data
96+
# Handle unexpected types (like int, float)
97+
result = pd.DataFrame([str(data)])
98+
9799
result = result.map(str).map(str.strip).map(str.lower).replace(r"\s+", " ", regex=True)
98-
if isinstance(data, str):
99-
result = result.iloc[0, 0]
100+
if isinstance(data, str) or (not isinstance(data, (list, pd.Series))):
101+
return result.iloc[0, 0]
100102
elif isinstance(data, (list, pd.Series)):
101-
result = result.iloc[:, 0]
103+
return result.iloc[:, 0]
102104
return result
103105

104106

0 commit comments

Comments
 (0)