Python - for loop over float

Hey everyone…

I’m new to python and messing with sales info, first thing I need to do is add everything that is more than 0 in Extended price, but after the loop that fn value is 0, which it should be in the millions.

Extended price is float64, also tried looping using
for i in range(len(sales[‘Extended Price’]))…the value returned was 1

sales = pd.read_csv(‘csv-utf8.csv’)

print(sum(sales[‘Extended Price’]))

def total_sales_logic():
total_sales = 0
for i in np.nditer(len(sales[‘Extended Price’])):
if i > 0:
total_sales += i
return total_sales

okay, so what did you do in the loop?
don’t just look at the final result, you did something to reach it. what?
find out what operation didn’t behave as you expected, look at what input you gave it and consider whether the input you feed into it is correct, and consider whether that’s at all the right operation

ionatan…i appreciate the time to help, but i’ve been looking at the code for awhile.

I’ve tried variations of the np.nditer and range commands, all result in wrong values for the fn or cause errors. I can’t find a reason/ code online that gets it to work.

At this point, i’d like code that will get the result i need and hopefully an understanding on how to work with floats.

(if the column is changed to int(), the range code works)