I need to set the value of a column based on a condition, but I only need to set it on the first 5 rows.
This is my statement for selecting the correct rows which works fine.
kunden_df.loc[kunden_df["Distanz"] == 1].iloc[0:amount_contracts]
However setting the value on the column (Betreuer) does not do a thing.
kunden_df.loc[kunden_df["Distanz"] == 1].iloc[0:amount_contracts]["Betreuer"] = value
I know this is a syntax problem and I have already found quite similar questions (like: Pandas/Python: Set value of one column based on value in another column) , but I cant make it work. Can you help?