Python list of doubles

I am having an issue of creating an array of floats. I have a loop that is scanning the rows of an attribute table and extracting numbers from it. SARAarea, truearea and rasterarea are all extracted from an attribute table and they should be floats. I am trying to use these numbers and do calculations with them and then insert them back into the attribute table. My main issue is adding floats to the list. I keep getting error messages that a float is not iterable or a float is not an attribute to append or extend. What is the best way to do this? I tried to create one loop that would getvalue and insert value into the attribute without using a list.But the searchcursor function only allows me to create two separate loops because there is a seachCursor and a UpdateCursor, it only allows me to do one task at a time.

This is my attempt at initializing the lists

approxTen=['f'] approxremaining=['f'] lessperc=['f'] moreperc=['f']‍‍‍‍‍‍‍‍

This is where I am getting my errors. The code is in a while loop of a searchCursor. "While row:".

approxTen=[SARAarea*truearea]/rasterarea approxremaining=truearea-approxTen lessperc=[approxTen/truearea]*100 moreperc=[approxremaining/truearea]*100 approxTen.append[approxTen] approxremaining.append[approxremaining] lessperc.append[lessperc] moreperc.append[moreperc]‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Common error I am getting below. Line 50 is line 7 in the code above. I have tried extend and append but neither worked and I haved tried putting float[] around the values of approxTen and the rest of them but it did not work.

For example: approxremaining= float[truearea-approxTen]

This is how I am inserting it back into the attribute table. Below is a separate loop then above code. Iam trying to loop through the list and add it to the attribute table.

while row3: row3[0]=approxTen[row3] row3[1]=approxremaining[row3] row3[2]=lessperc[row3] row3[3]=moreperc[row3] cursoru.updateRow[row3]‍‍‍‍‍‍‍‍‍‍‍‍

Video liên quan

Chủ Đề