【发布时间】:2021-09-25 15:49:53
【问题描述】:
我想根据另一列中的值从数据框的特定列中删除单元格值。
对于“匹配”列中包含“TRUE”的每一行,应删除“品牌总差异”列中的值(不是零,只是空)。
| variable | Difference Magnitude | Total Difference by Brand | Total Difference by Location | match |
|---|---|---|---|---|
| Total New Funding Sources | 1406904 | 5031189 | 4373182 | FALSE |
| Total New Funding Sources | 75821 | 5031189 | 4373182 | TRUE |
| Total New Funding Sources | 33692 | 5031189 | 4373182 | TRUE |
| Total New Funding Sources | 2627094 | 5031189 | 4373182 | TRUE |
| Total New Funding Sources | 400000 | 500000 | 4373182 | FALSE |
| Total New Funding Sources | 500000 | 500000 | 4373182 | TRUE |
| Total New Funding Sources | 1406904 | 5131189 | 4373182 | FALSE |
| Total New Funding Sources | 75821 | 5131189 | 4373182 | TRUE |
| Total New Funding Sources | 33692 | 5131189 | 4373182 | TRUE |
数据框应如下所示:
| variable | Difference Magnitude | Total Difference by Brand | Total Difference by Location | match |
|---|---|---|---|---|
| Total New Funding Sources | 1406904 | 5031189 | 4373182 | FALSE |
| Total New Funding Sources | 75821 | 4373182 | TRUE | |
| Total New Funding Sources | 33692 | 4373182 | TRUE | |
| Total New Funding Sources | 2627094 | 4373182 | TRUE | |
| Total New Funding Sources | 400000 | 500000 | 4373182 | FALSE |
| Total New Funding Sources | 500000 | 4373182 | TRUE | |
| Total New Funding Sources | 1406904 | 5131189 | 4373182 | FALSE |
| Total New Funding Sources | 75821 | 4373182 | TRUE | |
| Total New Funding Sources | 33692 | 4373182 | TRUE |
谢谢
【问题讨论】:
标签: python-3.x pandas dataframe duplicates conditional-statements