I am trying to calculate the percent AREA in each class. I have created a new percentage field and have tried to populate it using the following equation in python in the calculate field tool.

percent = float(!Area_ha!)/ sum(!Count!)

in other words I want to take the area of each record and divide it by the total area.

I am getting the following error

  File "expression", line 1, in module

TypeError: 'float' object is not iterable
  • 1
    I know this is besides the point but, if you want to divide by total area shouldn't you be using sum(!Area_ha!)?, Also you do not need the percent= part if it is included in your expression.
    – yanes
    Commented Jan 27, 2016 at 21:26
  • 1
    Is your data stored in a shapefile, file geodatabase feature class or somewhere else? What are the data types of percent, Area_ha and Count? What does your tool dialog look like prior to running it to see this error? Please use the edit button beneath your question to revise it with any clarifications.
    – PolyGeo
    Commented Jan 27, 2016 at 21:47
  • 2
    In python, sum only works with iterables such as lists and tuples. I'm assuming Count is a float. Do you want to sum all of the Count values in the the attribute table? If so, you will probably need a search cursor and store the value in a variable called "TotalCount" or something like that. There are plenty of posts on this site about search cursors. Alternatively, you could get the total beforehand and just divide by that number.
    – Fezter
    Commented Jan 27, 2016 at 22:46

2 Answers 2


A quick and easy way would be to:

  1. Add another column that has the total area. total_area. (or just take note of the total area and hard code it at step 3 as @Frezter suggested in the comments.
  2. Then create a percent_Area column with float property with the desired number of decimal points.
  3. Either use (!Area_ha!)/(!total_area!) using Python OR [Area_ha]/ [total_area] using VB,by doing a calculate field on the percent_Area field you created on step 2. As it is already float any fractions will be automatically saved in the column. if using hard coded area value use: [Area_ha]/ 'totalvalue' <- where you replace the total area value(in numbers) instead of 'totalvalue'

Note: if you are using Count because you are using a raster, the count gives you the total area only when you multiply it with the resolution for example if you have 10 pixels that are 2m by 2m. you need to do Count * 2* 2 to get the total area your raster covers. (well, roughly, as measurement and data representation errors could throw the figure off the exact area a bit)


You do not say whether you are working with raster data. I do not know much about python in ArcMap, but I know when you want to have a table of attributes in a raster file you need to convert to integer. Maybe you need to make the calculations in integer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.