title: filter pandas where some columns contain any of the words in a list
body: <p>I would like to filter a Dataframe. The resulting dataframe should contain  all the rows where in any of a number of columns contain any of the words of a list.</p>
  
  <p>I started to use for loops but there should be a better pythonic/pandonic way.</p>
  
  <p>Example:</p>
  
  <pre><code># importing pandas 
  import pandas as pd 
  
  # Creating the dataframe with dict of lists 
  df = pd.DataFrame({'Name': ['Geeks', 'Peter', 'James', 'Jack', 'Lisa'], 
                     'Team': ['Boston', 'Boston', 'Boston', 'Chele', 'Barse'], 
                     'Position': ['PG', 'PG', 'UG', 'PG', 'UG'], 
                     'Number': [3, 4, 7, 11, 5], 
                     'Age': [33, 25, 34, 35, 28], 
                     'Height': ['6-2', '6-4', '5-9', '6-1', '5-8'], 
                     'Weight': [89, 79, 113, 78, 84], 
                     'College': ['MIT', 'MIT', 'MIT', 'Stanford', 'Stanford'], 
                     'Salary': [99999, 99994, 89999, 78889, 87779]}, 
                     index =['ind1', 'ind2', 'ind3', 'ind4', 'ind5']) 
  
  
  df1 = df[df['Team'].str.contains("Boston") | df['College'].str.contains('MIT')] 
  print(df1) 
  </code></pre>
  
  <p>So it is clear how to filter columns individually that contain a particular word</p>
  
  <p>further on it is also clear how to filter rows per column containing any of the strings of a list:</p>
  
  <pre><code>df[df.Name.str.contains('|'.join(search_values ))]
  </code></pre>
  
  <p>Where search_values contains a list of words or strings.</p>
  
  <pre><code>search_values = ['boston','mike','whatever']
  </code></pre>
  
  <p>I am looking for a short way to code</p>
  
  <pre><code>#pseudocode
  give me a subframe of df where any of the columns 'Name','Position','Team' contains any of the words in search_values
  </code></pre>
  
  <p>I know I can do </p>
  
  <pre><code>df[df['Name'].str.contains('|'.join(search_values )) | df['Position'].str.contains('|'.join(search_values )) | df['Team'].contains('|'.join(search_values )) ]
  </code></pre>
  
  <p>but if I would have like 20 columns that would be a mess of a line of code</p>
  
  <p>any suggestion?</p>
  
  <p>EDIT Bonus:
  When looking in a list of columns i.e. 'Name','Position','Team' how to include also the index? passing ['index','Name','Position','Team'] does not work.</p>
  
  <p>thanks.</p>
  
  <p>I had a look to this:
  <a href="https://www.geeksforgeeks.org/get-all-rows-in-a-pandas-dataframe-containing-given-substring/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/get-all-rows-in-a-pandas-dataframe-containing-given-substring/</a></p>
  
  <p><a href="https://kanoki.org/2019/03/27/pandas-select-rows-by-condition-and-string-operations/" rel="nofollow noreferrer">https://kanoki.org/2019/03/27/pandas-select-rows-by-condition-and-string-operations/</a></p>
  
  <p><a href="https://stackoverflow.com/questions/28914078/filter-out-rows-based-on-list-of-strings-in-pandas">Filter out rows based on list of strings in Pandas</a></p>