crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG] An ascending numeric sequence is misread as a total row, hiding the last data row

Open Luckyou-d opened this issue 2 weeks ago • 0 comments

Description

total_row treats the last row as a total when a numeric column's last value equals the sum of the column above it. Any ascending arithmetic sequence satisfies that, so ordinary data silently disappears from describe, value_counts, group_by and the overview's column profile while rows still shows it:

item,amount     ->  describe: "2 rows (its total row, row 4, is left out)"
a,1
b,2
c,3

The same happens with 2,4,6 and 10,20,30 - three shapes that are far more likely to be data than a total. total_row is also what the strix/cursor reviews of #9389 kept landing on.

Expected behavior

A row that carries its own label is data, however neatly its numbers add up. A real total row has no row label, or one of the recognised ones ("Total", "Sum", ...). Both shapes the current tests cover keep working: ["Total", 6] matches the label branch, and [None, 6] has an empty first cell.

Environment

crewai-files on main (435262c), Python 3.13, Windows.

Reproduction

from crewai_files.spreadsheets.answers import Query, query, total_row
from crewai_files.spreadsheets.reading import parse

book = parse(b"item,amount
a,1
b,2
c,3
", "t.csv")
print(total_row(book.sheets[0].table()))       # 4, though this is data
print(query(book, "t.csv", Query(operation="describe")).splitlines()[1])
# data: 2 rows (its total row, row 4, is left out).

A fix with regression tests for the three sequences, plus the labelled and unlabelled total rows, is ready.

Luckyou-d avatar Nov 18 '26 09:11 Luckyou-d