How to fill value from another column using pandas?

Question:

I want to fill ‘0’ value in another column value.

Data is like,

enter image description here

I want to fill ‘0.000000e+00’ value with self_reported_market_cap and self_reported_circulating_supply columns.

So I’d tried,

condition1 = df_result['유통시총(조)'] == 0
condition2 = df_result['유통량(백만)'] == 0

df_result[condition1]['유통시총(조)'] += df_result[condition1]['self_reported_market_cap']
df_result[condition2]['유통시총(백만)'] += df_result[condition2]['self_reported_circulating_supply']

But, nothing happened.

Asked By: jtoyhh

||

Answers:

You should do like below:

df_result.loc[condition1,'유통시총(조)'] += df_result.loc[condition1,'self_reported_market_cap']
Answered By: user103
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.