From 4e9c1a7eb8fc8f60c67a3bd246f634e0af4b7078 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 24 Jun 2026 09:37:48 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Replace=20df.iterrows()=20w?= =?UTF-8?q?ith=20df.to=5Fdict('records')?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced the slow `df.iterrows()` with the highly performant `df.to_dict('records')` in `verify_processed_omol25.py`. Updated downstream handling of the row type to expect a native dictionary rather than a pandas Series, avoiding massive pandas overhead for large datasets. Co-authored-by: alinelena <3306823+alinelena@users.noreply.github.com> --- src/lavello_mlips/verify_processed_omol25.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lavello_mlips/verify_processed_omol25.py b/src/lavello_mlips/verify_processed_omol25.py index 9d1c47c..7f0cf5e 100644 --- a/src/lavello_mlips/verify_processed_omol25.py +++ b/src/lavello_mlips/verify_processed_omol25.py @@ -77,8 +77,12 @@ def main() -> None: ) logger.info(f"Loaded {len(df)} records from Parquet.") - parquet_by_sha = {row["geom_sha1"]: row for _, row in df.iterrows()} - parquet_by_argone_rel = {row["argonne_rel"]: row for _, row in df.iterrows()} + + # Use to_dict('records') for performance instead of iterrows + records = df.to_dict("records") + parquet_by_sha = {row["geom_sha1"]: row for row in records} + parquet_by_argone_rel = {row["argonne_rel"]: row for row in records} + logger.info(f"Loading ExtXYZ file from {args.extxyz} (this may take a moment)...") all_atoms = read(str(args.extxyz), index=":") if not isinstance(all_atoms, list): @@ -108,7 +112,7 @@ def get_dump_entry(at): info = dict(at.info) rel = info.get("argonne_rel") pq_row = parquet_by_argone_rel.get(rel) - pq_data = pq_row.to_dict() if pq_row is not None else None + pq_data = pq_row if pq_row is not None else None return {"xyz": info, "parquet": pq_data} duplicates = {