title: What's the efficient way to filter a python dictionary based on whether an element in a value list exists?
body: <p>I have a dictionary (table) defined like this:</p>
  <pre><code>table = {&quot;id&quot;: [1, 2, 3]}, {&quot;file&quot;: ['good1.txt', 'bad2.txt', 'good3.txt']}
  </code></pre>
  <p>and I have a list of bad candidates that should be removed:</p>
  <pre><code>to_exclude = ['bad0.txt', 'bad1.txt', 'bad2.txt']
  </code></pre>
  <p>I hope to filter the table based on if the file in a row of my table can be found inside to_exclude.</p>
  <pre><code>filtered = {&quot;id&quot;: [1, 2]}, {&quot;file&quot;: ['good1.txt', 'good3.txt']}
  </code></pre>
  <p>I guess I could use a for loop to check the entries one by one, but I was wondering what's the most python-efficient manner to solve this problem.</p>
  <p>Could someone provide some guidance on this? Thanks.</p>