10 ответов
+ 3
What is the variable type? DataFrame? Array? or are those just two lists?
In any way, you should iterate through with index and assign b[index] = 0 if a[index] == 0
Or at least this is how I understood your question.
+ 2
Kuba Siekierzyński Thank you so much. So kind of you. I really appreciate.
+ 1
fillna will affect everything.
Try the following, instead:
df.loc[df['a']==0, 'b'] = 0
https://code.sololearn.com/cUu3pQq9LdME/?ref=app
0
A and B are columns of a dataframe
0
Thank you Kiibo for replying
0
Thank you Kuba
0
𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 I tried like this
if df['a'] ==0:
df['b'].fillna(0,inplace=True)
0
Kuba Siekierzyński a and b are columns of a same dataframe df