df['Urban'] = np.where(df['population_1000'].gt(df['population_1000'].quantile(0.75)) & (df['road_class_1_100'].gt(0) | df['road_class_2_100'].gt(0) | df['road_class_3_100'].gt(df['road_class_3_100'].quantile(0.75))), 1, 0)

df['LowPop'] = np.where(df['population_1000'].lt(df['population_1000'].quantile(0.75)) & (df['road_class_1_100'].gt(0) | df['road_class_2_100'].gt(0)  | df['road_class_3_100'].gt(df['road_class_3_100'].quantile(0.75))), 1, 0)

df['FarFromRoad'] = np.where(df['Urban'] | df['LowPop'] = = 1, 0, 1)