title: Is there a module that can count occurrences of a list of strings in Python?
body: <p>I have defined a list that reads the contents of a number of files and stores all of them.
  How do I create a dataframe, with each filename in a row, and the corresponding columns count the occurrence of each word and output it.</p>
  
  <p>For the sake of example, assume this is all well-defined (but I can provide original code if needed):</p>
  
  <pre><code>#define list
  words = [ file1_contents, file2_contents ]
  
  file1_contents = "string with dogs, cats and my pet sea turtle that lives in my box with my other turtles."
  file2_contents = "another string about my squirrel, box turtle (who lives in the sea), but not my cat or dog".
  
  filter_words = ["cat", "dog", "box turtle", "sea horse"]
  </code></pre>
  
  <p>Output would be something like this:</p>
  
  <pre><code>output = {'file1'{'cat': 1, 'dog':1, 'box turtle': 1, 'sea horse': 0}, 'file2'{ ...}} 
  
  </code></pre>
  
  <p>I have attached an image of my end goal. I am just beginning to use python, so I'm not too sure about what package/module I would use here? I know pandas lets you work with dataframes.</p>
  
  <p>I had the idea of using <code>Counter</code> from <code>collections</code></p>
  
  <pre><code>from collections import Counter
  z = ['blue', 'red', 'blue', 'yellow', 'blue', 'red']
  Counter(z)
  Counter({'blue': 3, 'red': 2, 'yellow': 1})
  </code></pre>
  
  <p>BUT, here is where I am stuck. How do I organise a table in python which would look like the attached image?</p>
  
  <p>Example output:
  <a href="https://i.stack.imgur.com/EFgQv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EFgQv.jpg" alt="enter image description here"></a></p>