Suppose you have a pandas DataFrame df
with columns col1
, col2
, and col3
. You can filter the rows of the DataFrame based on the values of col1
and col2
using the following code:
main.py66 chars2 lines
where value1
is the desired value of col1
and value2
is the desired value of col2
. The &
operator combines two conditions to form a logical 'and' statement.
The resulting filtered_df
will contain only the rows where col1
equals value1
and col2
equals value2
.
gistlibby LogSnag