Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
tidy up code
Browse files Browse the repository at this point in the history
  • Loading branch information
kdutia committed Oct 3, 2023
1 parent 846674e commit 6fa5893
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cpr_data_access/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,11 +1134,11 @@ def from_huggingface(
for _, row in doc_df.iterrows()
]

doc_fields = doc_df.iloc[0].to_dict()

for k, v in doc_fields.items():
if isinstance(v, np.ndarray):
doc_fields[k] = list(v)
# pandas to_dict() stores sequences as numpy arrays, so we need to convert them back to lists
doc_fields = {
k: list(v) if isinstance(v, np.ndarray) else v
for k, v in doc_df.iloc[0].to_dict().items()
}

doc_metadata = document_metadata_model.parse_obj(
doc_fields
Expand Down

0 comments on commit 6fa5893

Please sign in to comment.