title: Getting unmatched Pandas rows based on regex
body: <p>I have a CSV file which contains 10 columns (c1 to c10) and it mainly has numeric data. I want to extract all those rows where any of the cell value does not match the decimal number pattern of "#####.###" (5 digits before the decimal point and 3 digits after.) So the regex which I have formed is  r'^\d{5}[.]\d{3}$' </p>
  
  <p>I have used ^ and $ because anything unmatched with the given format should be returned.</p>
  
  <p>If the single cell does not have above pattern, then entire row should be returned. Here is what I have tried:</p>
  
  <pre><code>Sample input can be (no. of columns does not really matter)-
  c1          c2           c3
  12345.455  14567.83333  14562.125
  14789.123  14725.456    1234567.124589
  21445.658  45678.899    45678.369
  </code></pre>
  
  <p>First 2 rows should be returned and last row is in correct format.</p>
  
  <pre><code>### What I have tried till now -
  
  df = pd.read_csv("table.csv") ## converting csv to dataframe
  pattern = r'^\d{5}[.]\d{3}$' 
  df = df.astype(str)  ## getting dataframe as string
  
  
  
  ### I am using ~ to negate as I need unmatched rows.
  
  df1 = df[~df['c1'].str.contains(pattern)]
  df2 = df[~df['c2'].str.contains(pattern)]
  df3 = df[~df['c3'].str.contains(pattern)]
  df4 = df[~df['c4'].str.contains(pattern)]
  df5 = df[~df['c5'].str.contains(pattern)]
  df6 = df[~df['c6'].str.contains(pattern)]
  df7 = df[~df['c7'].str.contains(pattern)]
  df8 = df[~df['c8'].str.contains(pattern)]
  df9 = df[~df['c9'].str.contains(pattern)]
  df10 = df[~df['c10'].str.contains(pattern)]
  
  final_df = pd.concat([df1,df2,df3,df4,df5,df6,df7,df8,df9,df10])
  print(final_df)
  </code></pre>
  
  <p>But this code returns some extra rows which are not supposed to be there.
  Any help..? A Similar question is <a href="https://stackoverflow.com/questions/45557050/return-the-unmatched-rows-from-the-regex-pattern">Return the unmatched rows from the regex pattern</a>.</p>