Skip to content

Commit

Permalink
fix: improve df to records performance (#28512)
Browse files Browse the repository at this point in the history
(cherry picked from commit 11164e2)
  • Loading branch information
dpgaspar authored and michael-s-molina committed May 30, 2024
1 parent 623913e commit 9626959
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions superset/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ def df_to_records(dframe: pd.DataFrame) -> list[dict[str, Any]]:
logger.warning(
"DataFrame columns are not unique, some columns will be omitted."
)
columns = dframe.columns
return list(
dict(zip(columns, map(_convert_big_integers, row)))
for row in zip(*[dframe[col] for col in columns])
)
records = dframe.to_dict(orient="records")

for record in records:
for key in record:
record[key] = _convert_big_integers(record[key])

return records

0 comments on commit 9626959

Please sign in to comment.