I have a data frame with the below columns, some of the IGFRESAS columns have data in them, but I'll only be replacing the data that doesn't exist based on these conditions - see print screen
I want to use the condition EV_EM == 0 then copy EV_RND to all the IGFREAS4X columns.
I got this to work for one column:
df["IGFREAS41"]=np.where(df['EV_EM'] == 0, df['EV_RND'], df["IGFREAS41"])
I tried this: columns = ["IGFREAS41", "IGFREAS43", "IGFREAS44", "IGFREAS42"] np.where(df['EV_EM'] == 0, df['EV_RND'], df[columns])
I got this error: ---> 13 np.where(df['EV_EM'] == 0, df['EV_RND'], df[columns])
File <array_function internals>:180, in where(*args, **kwargs)
ValueError: operands could not be broadcast together with shapes (13,) (13,) (13,4)