title: Replace pandas iterrows() with apply & lambda
body: <p>Working code to add a new column to Pandas DataFrame using iterrows(). But it is extremely slow</p>
  
  <pre><code>df1['Kite_Token'] =0
  
  for row,col in df.iterrows():
      df1.loc[row, 'Kite_Token'] = df_instrument[(df_instrument.exchange_token==col.SC_CODE) &amp; (df_instrument.exchange == 'BSE')].instrument_token.to_string(index=False)
  </code></pre>
  
  <p>Here is my try to use apply and lambda to the above code but am getting the copy warning. Any faster way to accomplish without warning message?</p>
  
  <pre><code>df1['Kite_Token']= df1['SC_CODE'].apply(lambda x : df_instrument[(df_instrument.exchange_token==x) &amp; (df_instrument.exchange == 'BSE')].instrument_token.to_string(index=False))
  
  SettingWithCopyWarning: 
  A value is trying to be set on a copy of a slice from a DataFrame.
  Try using .loc[row_indexer,col_indexer] = value instead
  </code></pre>