I have one calculation where it works great getting a variable in:
arcpy.management.CalculateField(sector_angle, 'Buffer', "getBuffer(!Area!)", "PYTHON3",
f"""def getBuffer(area):
if area < {median_area}:
return 1
if area > {median_area}:
return 2""",
"TEXT", "NO_ENFORCE_DOMAINS")
And I have another calculation on the same feature class where it does not work.
arcpy.management.CalculateField(sector_angle, 'Buffer_Radius', "setDistance(!Buffer!)", "PYTHON3",
f"""def setDistance(buffer):
if buffer == 1:
return {pnt[2]}
elif buffer == 2:
return {pnt[3]}""", "FLOAT")
Some example on how the variables look:
pnt[2] = 2043.8900146484375
pnt[3] = 4087.780029296875
The type of both variables is float, but the resulting 'Buffer_Radius' field contains only NaN.

I tried all sorts of stuff on how to get the variables into the code block, but while it was so easy in the first function, I don't have luck with the second one. How do I get my variables into the 'Buffer_radius' field?