Saturday, 7 September 2013

Identify elements of a dataframe satisfying a condition

Identify elements of a dataframe satisfying a condition

Suppose I have the following dataframe:
df = pd.DataFrame({'A':[1,2,3,400], 'B':[100,2,3,4]})
And I want to find the locations (by index and column) of every element
larger than 50, i.e. a correct output would be:
[(3,'A'), (0,'B')]
What would be the most pythonic way of doing this?

No comments:

Post a Comment