I have a df where column A is either blank or has a string in it. I tried to write the if statement (all columns are strings) below. Basically, if there is something (any value) in df[A], then the new column value will be a concatenation of columns A, B and C. If there is no value in df[A], then it will concatenate columns B and C.
the part where it's idf df[A] returns a true or false value, right? just like if I were to write bool(df[A]). So if the value is true, then it should execute the first block, if not, then it should execute the 'else' block.
if df[A]:
df[new_column] = df[column_A] + df[column_B] + df[column_C]
else:
df[new_column] = df[column_B]+df[column_C]
I get this error: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().