It could be null values that are throwing it off. For 'Expression' change it to
setAPN2(str(!PG_APN!).strip())
This will convert any null values to a string representation of 'None'. Then alter your function like below Even if this isn't what is causing your specific error, this is good practice to ensure against null values breaking your code. You would then need to alter your function as below to only work on non-null values. Also, you can wrap the whole thing in try and except blocks to analyze which values aren't calculating and why. If none of the records get calculated, it's probably an error in the logic. Can you post a screenshot of some of the sample record values in the PG_APN field?
def setAPN2(parcel):
if parcel != 'None':
try:
strValue = parcel[0:3] + '-' + parcel[3:5] + '-'
if len(parcel) <= 8:
strValue += parcel[-3:]
else:
strValue += parcel[-1:]
return strValue
execept:
pass