0

I know that one can compare a whole column of a dataframe and making a list out of all rows that contain a certain value with:

values = parsedData[parsedData['column'] == valueToCompare] 

But is there a possibility to make a list out of all rows, by comparing two columns with values like:

values = parsedData[parsedData['column01'] == valueToCompare01 and parsedData['column02'] == valueToCompare02] 

Thank you!

1 Answer 1

1

It is completely possible, but I have never tried using and in order to mask the dataframe, rather using & would be of interest in this case. Note that, if you want your code to be more clear, use ( ) in each statement:

values = parsedData[(parsedData['column01'] == valueToCompare01) & (parsedData['column02'] == valueToCompare02)] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.