title: DataFrame.apply() error: "<Series> is not a valid function for 'Series' object"
body: <p>I get an AttributeError from pandas.DataFrame.apply(). Despite that, the function appears to work, but I'd like to understand apply() better, so I'm posting this question anyway...</p>
  
  <p>I have two dataframes, like these:</p>
  
  <pre><code>a = pd.DataFrame(data = {
      'ID': ['123', '456', '789'],
      'TIME': [1.5, 2, 3]
  })
  
  b = pd.DataFrame(data = {
      'ID': ['123', '456', '789'] * 2,
      'TIME_START': [1, 3, 3, 2, 1, 5],
      'TIME_END': [5, 4, 6, 6, 3, 6],
      'CORR_KEY': ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr']
  })
  </code></pre>
  
  <p>I merge them like so:</p>
  
  <pre><code>c = a.merge(b, how = 'inner', on = 'ID')
  </code></pre>
  
  <p>And I get the following:</p>
  
  <pre><code>print(c)
  
      ID  TIME  TIME_START  TIME_END CORR_KEY
  0  123   1.5           1         5      abc
  1  123   1.5           2         6      jkl
  2  456   2.0           3         4      def
  3  456   2.0           1         3      mno
  4  789   3.0           3         6      ghi
  5  789   3.0           5         6      pqr
  </code></pre>
  
  <p>Now I need to drop records in <strong>c</strong> where <strong>TIME_START</strong> &lt;= <strong>TIME</strong> &lt;= <strong>TIME_END</strong> is FALSE. This way, I wind up with only records that have the relevant <strong>CORR_KEY</strong>. (For example, the correct <strong>CORR_KEY</strong> for <strong>ID</strong> 123 is abc, NOT jkl.)</p>
  
  <p>I use the following function, and apply it along the dataframe:</p>
  
  <pre><code>def drop_records(df):
      start_condition = df['TIME_START'] &lt;= df['TIME']
      end_condition = df['TIME'] &lt;= df['TIME_END']
  
      df.drop(df[~(start_condition) | ~(end_condition)].index, inplace = True)
  
      return df
  
  c = c.apply(drop_records(c))
  </code></pre>
  
  <p>The result is:</p>
  
  <blockquote>
    <p>AttributeError: 'ID' is not a valid function for 'Series' object</p>
  </blockquote>
  
  <p>HOWEVER, checking <strong>c</strong> again, I get the expected output:</p>
  
  <pre><code>print(c)
  
      ID  TIME  TIME_START  TIME_END CORR_KEY
  0  123   1.5           1         5      abc
  3  456   2.0           1         3      mno
  4  789   3.0           3         6      ghi
  </code></pre>
  
  <p>So, what causes the AttributeError?</p>
  
  <p>Thanks!</p>