title: Making a function that converts specific pandas columns into len and making a new dataframe based on those values
body: <p>I'm very new to programming.
  I'm doing a small project with pandas, and I need to create a function that, using a dataframe and 2 columns from that dataframe, outputs two dataframes.</p>
  <pre><code>dataframe = df
  
  def string_filter(dataframe, dataframest1, dataframest2):
      dataframe0 = dataframe[dataframe[dataframest2].notnull()]
         
      dataframe0[ dataframest1 + ' refined '] = dataframe0[dataframest1].str.len()
      dataframe0[ dataframest2 + ' refined '] = dataframe0[dataframest2].str.len()
      print(dataframe0)
      
      x == dataframe0[ dataframest1 + ' refined ']
      z == dataframe0[ dataframest2 + ' refined ']
     
      dataframe1 = dataframe0[x | z != 1] 
      dataframe2 = dataframe0[x | z == 1] 
      
      return(dataframe1, dataframe2)
  
  string_filter(dataframe, 'c1', 'c2')
  </code></pre>
  <p>Whenever I input c1 and c2 as a string, I'm always get this error message:</p>
  <pre><code>KeyError: ('c1', 'c2')
  
  The above exception was the direct cause of the following exception:
  
  KeyError                                  Traceback (most recent call last)
  Input In [28], in &lt;cell line: 1&gt;()
  ----&gt; 1 string_filter(dataframe, &quot;c1&quot;,&quot;c2&quot;)
  </code></pre>
  <p>How do I fix it so when I input dataframest1, dataframest2 as strings I get two dataframes?</p>
  <p>Thanks</p>