df.loc[:, ('label')][df.loc[:, ('distance')] <= 0.1] = 1
df.loc[:, ('label')][(0.1 < df.loc[:, ('distance')]) & (df.loc[:, (
    'distance')] <= 0.5)] = 2
df.loc[:, ('label')][df.loc[:, ('distance')] > 0.5] = 3
Optimizing for loop in python