尝试在我的代码中合并以下case语句。你知道吗
d1['newcol'] = np.where((d1['business_name'] == 'HELP')&(d1['level'] == 'Component'), d1['component'], np.where((d1['business_name'] == 'HELP')&(d1['level'] == 'Package'),d1['package'], np.where(d1['business_name'] == 'PHELPS',d1['reporting'])))
或者案例伪代码看起来像:
newcol=case WHEN ((business_name = 'HELP' AND level = 'Component')) THEN component WHEN ((business_name = 'HELP' AND level = 'Package')) THEN package WHEN (business_name = 'PHELS') THEN reporting END
我得到的错误是:
ValueError: either both or neither of x and y should be given
任何帮助都将不胜感激。你知道吗
这里有一个方法可以实现这个结果。使用其他样本数据。你知道吗
您可能希望在数据帧的所有行上应用lambda函数。你知道吗
相关问题 更多 >
编程相关推荐