2
此问题是Pandas conditional creation of a series/dataframe column的扩展。 如果我们有这个数据帧:熊猫条件创建新的数据帧列
Col1 Col2
1 A Z
2 B Z
3 B X
4 C Y
5 C W
,我们想做的相当于:
if Col2 in ('Z','X') then Col3 = 'J'
else if Col2 = 'Y' then Col3 = 'K'
else Col3 = {value of Col1}
我怎么能这样做呢?
如果我或另一种答案是有帮助的,不要忘了[接受] (http://meta.stackexchange.com/a/5235/295067)。谢谢。 – jezrael