Asked • 04/30/19

Select rows from a DataFrame based on values in a column in pandas?

How to select rows from a DataFrame based on values in some column in pandas? In SQL I would use: select * from table where colume_name = some_value. *I tried to look at pandas documentation but did not immediately find the answer.*

1 Expert Answer


Ethan J.

Use an DataFrame within an DataFrame structure. df['A']>1 returns a 1-d boolean vector, indexing df with that vector will return only the rows where the boolean vector's value is True. Pandas documentation can be confusing. I recommend using this link to find detailed explanation for various types of indexing.


Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.