I get this error when trying to calculate a field:
ERROR 000539: Error running expression: u"5359" / 5312094.0
Traceback (most recent call last):
File "<expression>", line 1, in <module>
TypeError: unsupported operand type(s) for /: 'str' and 'float'
Failed to execute (CalculateField).
I downloaded census tracts for a county in Ohio, then I joined thiswith population data from American Fact Finder. After I export the data I joined, I add a new field "Pop Density"... To calculate this new field I need to divide Total population "HD01_S001" with the area of the Census tract "ALAND".. When I put this expression in the calculate field command I get the error above.. Don't understand what could be going wrong here...
Hello! By my best understanding the division is not working because the field types are not the same. Somehow you need to get the population density from a string to a float.
I don't know of an elegant way to do this, you could brute force it by creating a new field make the type double and run a quick calculation so that the new field equals the values of "HD01_S001". After that is done you should be able to do your original calculation with the new field substituting for the population density field.
Hope someone has a more finessed solution for you!
For Python you should be able to
float(!HD01_S001!)/float(!ALAND!)