Skip to content
Advertisement

How do I select and store columns greater than a number in pandas?

I have a pandas DataFrame with a column of integers. I want the rows containing numbers greater than 10. I am able to evaluate True or False but not the actual value, by doing:

JavaScript

I don’t use Python very often so I’m going round in circles with this.

I’ve spent 20 minutes Googling but haven’t been able to find what I need….

Edit:

JavaScript

Advertisement

Answer

Sample DF:

JavaScript

present only those rows where b > 10

JavaScript

Minimums (for all columns) for the rows satisfying b > 10 condition

JavaScript

Minimum (for the b column) for the rows satisfying b > 10 condition

JavaScript

UPDATE: starting from Pandas 0.20.1 the .ix indexer is deprecated, in favor of the more strict .iloc and .loc indexers.

Advertisement