title: Pandas str.contains for exact matches of partial strings
body: <p>I have a DataFrame (I'll call it <code>test</code>) with a column containing file paths and I want to filter the data using a partial path.  </p>
  
  <pre><code>                              full_path
  0    C:\data\Data Files\BER\figure1.png
  1    C:\data\Data Files\BER\figure2.png
  2    C:\data\Previous\Error\summary.png
  3        C:\data\Data Files\Val\1x2.png
  4        C:\data\Data Files\Val\2x2.png
  5         C:\data\Microscopy\defect.png
  </code></pre>
  
  <p>The partial path to find is:</p>
  
  <pre><code>ex = 'C:\\data\\Microscopy'
  </code></pre>
  
  <p>I've tried <code>str.contains</code> but,</p>
  
  <pre><code>test.full_path.str.contains(ex)
  
  0    False
  1    False
  2    False
  3    False
  4    False
  5    False
  </code></pre>
  
  <p>I would have expected a value of <code>True</code> for index 5.  At first I thought the problem might be with the path strings not actually matching due to differences with the escape character, but:</p>
  
  <pre><code>ex in test.full_path.iloc[5]
  </code></pre>
  
  <p>equals <code>True</code>.   After some digging, I'm thinking the argument to <code>str.contains</code> is supposed to be a regex expression so maybe the "\"s in the partial path are messing things up?</p>
  
  <p>I also tried:</p>
  
  <pre><code>test.full_path.apply(lambda x: ex in x)
  </code></pre>
  
  <p>but this gives <code>NameError: name 'ex' is not defined</code>.  These DataFrames can have a lot of rows in them so I'm also concerned that the <code>apply</code> function might not be very efficient.</p>
  
  <p>Any suggestions on how to search a DataFrame column for <em>exact</em> partial string matches?</p>
  
  <p>Thanks!</p>