我正在尝试使用assign有条件地为列赋值。你知道吗
我尝试使用pandas assign创建一个新列,并在列SV\u length指定的长度值为>;=50时将其标记为SV,在长度为<;50时标记为InDel。你知道吗
df3=df2.assign(InDel_SV='InDel' if df2.sv_length < 50 else 'SV')
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
其他示例使用np.哪里. 为什么我要用numpy?这个简单的功能不应该是熊猫的一部分吗?你知道吗
https://chrisalbon.com/python/data_wrangling/pandas_create_column_using_conditional/
通过使用
apply
支持这种语法。你知道吗但是,为了提高性能,建议您使用numpy,因为apply is a slow convenience function。pandaic的方法是使用
numpy.where
:相关问题 更多 >
编程相关推荐