Whenever I perform the Summarize Within tool in ArcGIS Pro and use the graduated colors symbology on the resulting feature class, I end up with something that looks like this:


Is there a way to remove all those zeros i.e. can I set the results to zero decimal places using Arcpy for ArcGIS Pro?

I know how to do it manually without arcpy but I would like to be able to do it using python so that I can implement it into a larger piece of script.

closed as off-topic by BERA, whyzar, nmtoken, MaryBeth, aldo_tapia Dec 18 '17 at 14:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – BERA, whyzar, nmtoken, MaryBeth, aldo_tapia
If this question can be reworded to fit the rules in the help center, please edit the question.

  • it looks like the input fields are Double-Fields, is that true? You could just add a new field (as a long integer with arcpy.AddField_management and insert/calculate the values from the given field using python (then delete the old field). Would that be an option? If the input fields are integer fields, the results are without the zeros? There might be also other solutions. – GIS7 Dec 18 '17 at 14:07

The break labels of the graduated colors symbology can be overwritten with arcpy:

p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps()[0]
lyr = m.listLayers("layer_name")[0]
sym = lyr.symbology
if sym.renderer == "GraduatedColorsRenderer":
    breaks = sym.renderer.classBreaks
    for b in breaks:
        b_int = b.label[0:-7]
        b.label = b_int
lyr.symbology= sym

See GraduatedColorsRenderer for reference. I don't have ArcGIS Pro and haven't tested the code above but the equivalent in ArcMap works fine:

mxd = arcpy.mapping.MapDocument("current")
lyr = arcpy.mapping.ListLayers(mxd, "layer_name")[0]
if lyr.symbologyType == "GRADUATED_COLORS":
    c = []
    labels = lyr.symbology.classBreakLabels
    for l in labels:
    lyr.symbology.classBreakLabels = c
  • I think this is what I'm looking for; however, when I try the code I get the following error: Traceback (most recent call last): File "<string>", line 8, in <module> TypeError: 'ClassBreak' object is not subscriptable – Matt A. Dec 18 '17 at 14:25
  • I've modified the code slightly, could you try it? classBreaks and its label property are read & write, so it should be possible to modify them. – GISGe Dec 18 '17 at 14:32
  • I tried it and got the same error. However, I am only changing the layer_name. I'm a little confused on what you mean by modify classBreak – Matt A. Dec 18 '17 at 14:40
  • I've fixed one more error in my code. Sorry, I can't test it. Could you try again? What you want to do here is modify the label property of the classBreaks property of the renderer property of the symbology property of your layer... Can you follow along? :) – GISGe Dec 18 '17 at 14:45
  • Sorry I'm having a hard time understanding. Is that something I do inside or outside of the code? – Matt A. Dec 18 '17 at 15:07

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