How does for loops and elif work with python pandas?
Instead of just setting values for specific rows (i.e. rows where fclass is equal to the feature), you are setting the whole column (df.weight) with the value. Given that the last feature of df.class is probably bus_stop, which has a weight of 150 based on your logic, the final output will have a weight column filled with only values of 150.
There are multiple ways of getting to the output you want: (1) you can use .apply with a function containing the logic you want, (2) use the .loc method to set values for just the rows you want (so just the rows where the fclass column has a specific value) in combination with a loop, or even better, (3) use numpy.where/numpy.select to set all values at once without looping over the different features.
# method 1
def weight_function(row):
    if row[&quot;fclass&quot;] == &quot;bus_stop&quot;:
        return 150
    elif row[&quot;fclass&quot;] == &quot;taxi&quot;:
        return 100
    else:
        return 50
        
df[&quot;weight&quot;] = df.apply(weight_function, axis=1)

# method 2
for feature in df[&quot;fclass&quot;].unique():
    if feature == &quot;bus_stop&quot;:
        df.loc[df[&quot;fclass&quot;] == feature, &quot;weight&quot;] = 150
    elif feature == &quot;taxi&quot;:
        df.loc[df[&quot;fclass&quot;] == feature, &quot;weight&quot;] = 100
    else:
        df.loc[df[&quot;fclass&quot;] == feature, &quot;weight&quot;] = 50
        
# method 3
import numpy as np

conditions = [df[&quot;fclass&quot;] == &quot;bus_stop&quot;, df[&quot;fclass&quot;] == &quot;taxi&quot;, ~df[&quot;fclass&quot;].isin([&quot;bus_stop&quot;, &quot;taxi&quot;])]
choices = [150, 100, 50]
df[&quot;weight&quot;] = np.select(conditions, choices)