I've been trying to update the symbology of a layer on my Python script. The layer that is to be updated shows the percentage of an age range in each region across a county. I have created a test layer (as suggested on GraduatedColorsSymbology ArcPy Website) which copies the symbology of the test layer to the layer I am editing. I have set the symbology of this test layer to use the same dataset as the new layer, but uses a different age range (0 - 16 years).
This worked as expected, so now I want to update the Symbology to use a different age range (65 and Over) using the GraduatedColorsSymbology ArcPy page.
Below is my code:
mxd = arcpy.mapping.MapDocument(r"C:\MyMaps\Ages.mxd")
df = arcpy.mapping.ListDataFrames(mxd)
updateLayer = arcpy.mapping.ListLayers(mxd, "Age_Range")
sourceLayer = arcpy.mapping.Layer(r"C:\MyLayers\TEST_LAYER.lyr")
arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True)
if updateLayer.symbologyType == "GRADUATED_COLORS":
updateLayer.symbology.valueField = "PCT_65_OVR"
updateLayer.symbology.numClasses = 5
When I execute this code, I get the error
ValueError: PCT_65_OVR. I made sure that the attribute name in the code is the same as what is on the symbology layer, so not sure why I am getting this code.