[英]How to fill a pandas dataframe column using a value from another dataframe column
[英]How to fill value from another column using pandas?
我想在另一列值中填充“0”值。
數據就像,
我想用 self_reported_market_cap 和 self_reported_circulating_supply 列填充“0.000000e+00”值。
所以我試過,
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']
但是,什么也沒有發生。
你應該這樣做:
df_result.loc[condition1,'유통시총(조)'] += df_result.loc[condition1,'self_reported_market_cap']
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.