I have a dataframe called “nums” and am trying to find the value of the column “angle” by specifying the values of other columns like this:
JavaScript
x
2
1
nums[(nums['frame']==300)&(nums['tad']==6)]['angl']
2
When I do so, I do not get a singular number and cannot do calculations on them. What am I doing wrong? nums
Advertisement
Answer
First of all, in general you should use .loc
rather than concatenate indexes like that:
JavaScript
1
2
1
>>> s = nums.loc[(nums['frame']==300)&(nums['tad']==6), 'angl']
2
Now, to get the float, you may use the .item()
accessor.
JavaScript
1
3
1
>>> s.item()
2
-0.466331
3