Давайте попробуем использовать pd.cut
pd.cut(intersections['incident_ct'],bins=[4,13,31,100,..],labels=[1,2,4,8,16])
Исправьте ваш код
def incident(count):
... if count['incident_ct']<= 4:
... val = 1
... elif count['incident_ct']>4 and count['incident_ct']<= 13: # 25 to 50%
... val = 2
... elif count['incident_ct'] >13 and count['incident_ct']<=31: # 50 to 75%
... val = 4
... elif count['incident_ct'] >31 and count['incident_ct']<=100: # 75 to 95%
... val = 8
... else:
... val = 16
... return val