fix: improve df to records performance (#28512)

This commit is contained in:
Daniel Vaz Gaspar 2024-05-15 15:30:23 +01:00 committed by GitHub
parent 65e0d54fa5
commit 11164e2450
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 5 deletions

View File

@ -48,8 +48,10 @@ def df_to_records(dframe: pd.DataFrame) -> list[dict[str, Any]]:
logger.warning( logger.warning(
"DataFrame columns are not unique, some columns will be omitted." "DataFrame columns are not unique, some columns will be omitted."
) )
columns = dframe.columns records = dframe.to_dict(orient="records")
return list(
dict(zip(columns, map(_convert_big_integers, row))) for record in records:
for row in zip(*[dframe[col] for col in columns]) for key in record:
) record[key] = _convert_big_integers(record[key])
return records