-2
df_Import.update(df_Import["QUALIFIER"].where(df_Import["TYPE"].str.contains("LM")), df_Import["QUALIFIER"]"Leistung")

I am trying to update the empty slot in my column df_Import["QUALIFIER"] if the condition, that the other column df_Import["TYPE"] contains "LM" inside.

But how can I tell my program to write "Leistung" inside the ["QUALIFIER"] column if the condition matches?

yannickhau
  • 385
  • 1
  • 13

1 Answers1

0
df_Import["QUALIFIER"] = df_Import.apply(lambda x: 'Leistung' if 'LM' in x["TYPE"] else x["QUALIFIER"] , axis = 1)
Rahul Khanna
  • 316
  • 3
  • 12
  • https://stackoverflow.com/questions/54432583/when-should-i-ever-want-to-use-pandas-apply-in-my-code – ansev Feb 27 '20 at 11:59