title: How to invert a regular expression in pandas filter function
body: <p>I have the following pandas dataframe <code>df</code> (which is actually just the last lines of a much larger one):</p>
  
  <pre><code>                           count
  gene                            
  WBGene00236788                56
  WBGene00236807                 3
  WBGene00249816                12
  WBGene00249825                20
  WBGene00255543                 6
  __no_feature            11697881
  __ambiguous                 1353
  __too_low_aQual                0
  __not_aligned                  0
  __alignment_not_unique         0
  </code></pre>
  
  <p>I can use <code>filter</code>'s <code>regex</code> option to get only the lines starting with two underscores:</p>
  
  <pre><code>df.filter(regex="^__", axis=0)
  </code></pre>
  
  <p>This returns the following:</p>
  
  <pre><code>                           count
  gene                            
  __no_feature            11697881
  __ambiguous                 1353
  __too_low_aQual                0
  __not_aligned                  0
  __alignment_not_unique         0
  </code></pre>
  
  <p>Actually, what I want is to have the complement: Only those lines that do not start with two underscores.</p>
  
  <p>I can do it with another regular expression: <code>df.filter(regex="^[^_][^_]", axis=0)</code>.</p>
  
  <p><strong>Is there a way to more simply specify that I want the inverse of the initial regular expression?</strong></p>
  
  <p><strong>Is such regexp-based filtering efficient?</strong></p>
  
  <h3>Edit: Testing some proposed solutions</h3>
  
  <p><code>df.filter(regex="(?!^__)", axis=0)</code> and <code>df.filter(regex="^\w+", axis=0)</code> both return all lines.</p>
  
  <p>According to the <code>re</code> module documentation, the <code>\w</code> special character actually includes the underscore, which explains the behaviour of the second expression.</p>
  
  <p>I guess that the first one doesn't work because the <code>(?!...)</code> applies on what follows a pattern. Here, "^" should be put outside, as in the following proposed solution: </p>
  
  <p><code>df.filter(regex="^(?!__).*?$", axis=0)</code> works.</p>
  
  <p>So does <code>df.filter(regex="^(?!__)", axis=0)</code>.</p>