I’m trying to sum the first 12 rows of a dataset. Currently I have a total of all the rows.
total = 0
for row in pds:
total += row
How do I only sum the first 12 (assuming there are more than 12)?
Might be an even easier route, but could use a while loop instead of a for loop. That will let you specify the number of iterations versus using the full row quantity.
Yeah, I’m not sure how to apply a count while iterating though the “rows in pds:”
total = sum([row for row in pds[:12]])
Ahh, I was trying to add the limit to row. Awesome thanks