title: how to filter rows that satisfy a regular expression via pandas
body: <p>I'm trying to figure out a way to to select only the rows that satisfy my regular expression via Pandas. My actual dataset, data.csv, has one column(the heading is not labeled) and millions of row. The first four rows look like:</p>
  
  <pre><code>5;4Z13H;;L
  5;346;4567;;O
  5;342;4563;;P
  5;3LPH14;4567;;O
  </code></pre>
  
  <p>and I wrote the following regular expression </p>
  
  <pre><code>([1-9][A-Z](.*?);|[A-Z][A-Z](.*?);|[A-Z][1-9](.*?);)
  </code></pre>
  
  <p>which would identify <code>4Z13H;</code> from row 1 and <code>3LPH14;</code> from row 4. Basically I would like pandas to filter my data and select rows 1 and 4. 
  So my desired output would be </p>
  
  <pre><code>5;4Z13H;;L
  5;3LPH14;4567;;O
  </code></pre>
  
  <p>I would then like to save the subset of filter rows into a new csv, filteredData.csv. So far I only have this:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  import sys
  import re
  
  
  sys.stdout=open("filteredData.csv","w")
  
  def Process(filename, chunksize):
      for chunk in pd.read_csv(filename, chunksize=chunksize):
          df[0] = df[0].re.compile(r"([1-9][A-Z]|[A-Z][A-Z]|[A-Z][1-9])(.*?);")
          sys.stdout.close()
  
  
  if __name__ == "__main__":
      Process('data.csv', 10 ** 4)
  </code></pre>
  
  <p>I'm still relatively new to python so the code above has some syntax issues(I'm still trying to figure out how to use pandas chunksize). However the main issue is filtering the rows by the regular expression. I'd greatly appreciate anyone's advice</p>