title: Defining a function from two columns in Pandas
body: <p>I am trying to convert a value, my first column, based on the units which is a second column, I have tried the following:</p>
  
  <pre><code>def my_conversion():
      for x in df['unit']:
          if x == 'b1':
              return(df['value'] * 0.125)
          elif x == 'b2':
              return(df['value'] * 0.25)
          elif x == 'b3':
              return(df['value'] * 0.00781)
          elif x == 'b4':
              return(df['value'] / 3785411800000)
          else:
              return(df['value'])
  </code></pre>
  
  <p>Then I am using apply to create a new column:</p>
  
  <pre><code>df['value_converted'] = df['value'].apply(my_conversion)
  </code></pre>
  
  <p>I keep getting the following error:</p>
  
  <pre><code>my_conversion() takes 0 positional arguments but 1 was given
  </code></pre>