Will It Vibe logoWill It Vibe?
PERF-016Low severity-4 points

pd.concat() called inside a loop

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 4 points from that category, once per scan, no matter how many places it turns up.

What it detects

pd.concat() runs once per loop iteration inside a file that imports pandas, rebuilding and re-copying the growing DataFrame every time (O(n^2) in the number of iterations). Collect the pieces in a plain Python list and call pd.concat() once, after the loop. Heuristic: gated on the file importing pandas so pd is unlikely to be an unrelated identifier.

Why it matters

pd.concat() called once per loop iteration rebuilds and re-copies the entire growing DataFrame every time, so the total copying work grows quadratically with the number of iterations. This is a very common mistake in data-processing scripts that grew organically (start small, work fine in testing, then get slow on real-sized data). It is also the direct replacement people reach for now that DataFrame.append() has been removed from pandas, so it shows up in code that was recently migrated off append() without also fixing the underlying loop.

How to fix it

Collect the individual pieces (DataFrames, Series, or rows) in a plain Python list as you loop, and call pd.concat(list_of_pieces) exactly once after the loop finishes. This does the concatenation in one pass instead of n.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks