PROBLEM
In ArcMap, when the Python parser is used in the Field Calculator to carry out a division operation, integers are returned instead of decimals.
An example of the Python expression is as follows:
!VEHICLE_THEFT!/!POPULATION!
The division operation using the Field Calculator returns 0 for all fields.
![[O-Image]](https://webapps-cdn.esri.com/CDN/support-site/technical-articles-images/000012400/00N39000003LL24-0EM39000000wdbZ.png)
This is by design. Python 2.x is designed to return integers when dividing whole numbers regardless of the field type. For example, 1/9=0.
In the attribute table, create a float type field. This allows Python to return a decimal in the result. After creating the new field, apply the Python script.
![[O-Image]](https://webapps-cdn.esri.com/CDN/support-site/technical-articles-images/000012400/00N39000003LL2C-0EM39000000wdbU.png)
![[O-Image] [O]](https://webapps-cdn.esri.com/CDN/support-site/technical-articles-images/000012400/00N39000003LL2C-0EM39000000wdbQ.png)
![[O-Image]](https://webapps-cdn.esri.com/CDN/support-site/technical-articles-images/000012400/00N39000003LL2C-0EM39000000wdbW.png)
![[O-Image]](https://webapps-cdn.esri.com/CDN/support-site/technical-articles-images/000012400/00N39000003LL2C-0EM39000000wdbP.png)
float(!FieldName1!/!FieldName2!)
Note: The code provided is for the input of the type float.
![[O-Image]](https://webapps-cdn.esri.com/CDN/support-site/technical-articles-images/000012400/00N39000003LL2C-0EM39000000wdbV.png)
Article ID: 000012400
Get help from ArcGIS experts
Start chatting now