How to filter rows that contain specific text from entire DataFame and not just one column?

Viewed 16

Let us say I have a DataFrame that looks like this:

Name Name Name Name
Adam Ron Bob Ron
Ron Bob Ron Adam
Ron Ron Adam Kelly

I want to create a filter that will return all of the rows that contain the name "Bob". Other suggestions for a problem like this specify a column to look for the word Bob, but I need it to check the entire dataframe for the name Bob and return the rows that contain the word Bob in any of the columns. Like so,

Name Name Name Name
Adam Ron Bob Ron
Ron Bob Ron Adam

As you can see, I only want the rows that contain the name Bob in any of its columns.

I do not want to need to specify what column the code should look into because the column names can change. Is there a way to do this without writing out every column name into the code and simply have it check the entire dataframe?

0 Answers
Related