I got the following DataFrame:
System R System_num
0 CO 0.8 1
1 CO 0.9 1
2 CO 1.0 1
3 CO 1.2 1
4 CO 1.4 1
5 CO 0.8 2
6 CO 0.9 2
7 CO 1.0 2
8 CO 1.2 2
9 CO 1.4 2
10 CO 0.8 3
I would like to return the index of the line for which R = 1.4 and System_num = 2. I've tried by:
df.ix[df.System_num == 2 & df.R == 1.4].index
Though the error message is returning:
print df.ix[df.System_num == 2 & df.R == 1.4].index
File "/apps/anaconda/lib/python2.7/site-packages/pandas/core/ops.py", line 834, in wrapper
na_op(self.values, other),
File "/apps/anaconda/lib/python2.7/site-packages/pandas/core/ops.py", line 805, in na_op
x.dtype, type(y).__name__))
TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]
What am I doing wrong?
df.ix[(df.System_num == 2) & (df.R == 1.4)].indexyou need parenthesis around the comparison also see here..ixis finally being deprecated!!!