4

In this attribute table, "DISTANCE" field name created with this python expression (in Field Claculator):

str( !Shape_Leng! ) + !field_name!

enter image description here

Everything works fine.

But I seek a way to get on 1 number of decimal place and not 9 places as in the result. In the Field Properties the option to change is blocked.

enter image description here

enter image description here

  • 3
    Perhaps easier to create a new float field, set the decimal place to 1 and copy over the values from !Shape_Leng!. Then use this in your expression above. – Joseph Nov 17 '16 at 11:03
  • can you write it as an answer please? i can't understand you. – newGIS Nov 17 '16 at 11:07
  • 3
    You can also use Python function round: str( round(!Shape_Leng!,1) ) + !field_name! – BERA Nov 17 '16 at 11:17
  • Also check this post: Rounding column in attribute table using ArcGIS Field Calculator? – Joseph Nov 17 '16 at 11:18
10

'%.1f %s' % (!SHAPE_Leng!, !field_name!)

%.1f represents float with 1 decimal digit. Replace it with %.2f to get 2 digits and so on. %s is a string.

Or you can use format()

String Formatting Operations on Python site

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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