比较数据帧中的两列值

时间:2016-11-08 05:58:43

标签: python pandas compare multiple-columns

我有一个csv数据框,如下所示,我想比较两个列值并生成第三列,如果值相同则会返回True,而不是返回False,如何与熊猫python相比?

one two
1   a
2   b
3   a
4   b
5   5
6   6
7   7
8   8
9   9
10  10

1 个答案:

答案 0 :(得分:1)

如果值混合在一起($category = Mage::getModel('catalog/category')->load(' Mage::registry('current_category')->getId() '); //You will get current category id use passing value. $productCollection = $category->getProductCollection(); foreach($productCollection as $product) { echo $product->getName(); } string),则需要

int

但如果值未混合,则需要to_numeric - 第一列的df['three'] = df.one == df.two dtype,第二列为int,显然为object且列{ {1}}不是string值,因为带有参数one的{​​{1}}会返回NaN非数字值:

to_numeric

使用Series.eq加快解决方案:

errors='coerce'
相关问题