1
我想基于不同列的内容在指定索引添加一列:蟒蛇大熊猫基于条件语句添加栏目内容
df.insert(10, 'Escalation Status', np.where(df['Reasons for escalation'] == '', 'FALSE', 'TRUE'))
所以,当柱“的升级理由”不能为空,写入“FALSE”,如果不是,则在新创建的“升级状态”列中写入“TRUE”。
我的问题:无论“升级原因”字段中是否有任何内容,内容始终为“真”。
输出示例:
Country,Date,Vendor,Product Family,Case number,Reseller Name,OpeningDate,Closing Date,Case Status,Topic,Escalation Reason,Reasons for escalation
DEU,28.10.2016,VENDOR,,201610281078864,,28.10.2016,28.10.2016,closed,Software issue,TRUE,Software
DEU,28.10.2016,VENDOR,,201610281078862,,28.10.2016,28.10.2016,closed,Config help,TRUE,
第一行是正确的(理由升级,是不是空的,它包含“软件”),但第二行应该是“假”,为理由升级是空
感谢
这样做,非常感谢。 – f0rd42
很高兴能帮到你! – jezrael