title: Assign dataframe to variable outside for loop or use it directly inside for loop in Python
body: <p>option 1:</p>
  <pre><code>a = np.unique(df.values)
  for i in range():
    if df2.loc[i,'col1'] in a:
      df2.loc[i,'col2'] = 'Ok'
    else:
      df2.loc[i,'col2'] = 'No'
  </code></pre>
  <p>option 2:</p>
  <pre><code>for i in range():
    if df2.loc[i,'col1'] in np.unique(df.values):
      df2.loc[i,'col2'] = 'Ok'
    else:
      df2.loc[i,'col2'] = 'No'
  </code></pre>
  <p>Which is better in terms of memory and speed in Python?</p>
  <p>Edited for clarity on the operation inside the for loop.</p>