簡體   English   中英

如何使用 pandas 填充另一列的值?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM