title: Find values in a Pandas dataframe and insert the data in a column of another Pandas dataframe
body: <p>I have a dataframe that I need to convert the Custom Field column rows to columns in a second dataframe. This part I have managed to do and it works fine.</p>
  <p>The problem is that I need to add the corresponding values from the id column to the respective columns of the second dataframe.</p>
  <p>Here is an example:</p>
  <p>This is first dataframe:</p>
  <p><a href="https://i.stack.imgur.com/FT3mc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FT3mc.png" alt="enter image description here" /></a></p>
  <p>This is the second dataframe, with the columns already converted.</p>
  <p><a href="https://i.stack.imgur.com/QFml6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QFml6.png" alt="enter image description here" /></a></p>
  <p>But I would like to add the values corresponding to the id column of the first dataframe to the second dataframe:</p>
  <p><a href="https://i.stack.imgur.com/OT62e.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OT62e.png" alt="enter image description here" /></a></p>
  <p>Attached is the code:</p>
  <pre><code>import pandas as pd
  Data = {
  &quot;Custom Field&quot;: [&quot;CF1&quot;, &quot;CF2&quot;, &quot;CF3&quot;],
  &quot;id&quot;: [50, 40, 45],
  &quot;Name&quot;: [&quot;Wilson&quot;, &quot;Junior&quot;, &quot;Otavio&quot;]
  }
  
  ### create the dataframe ###
  df = pd.DataFrame(data)
  print(df)
  
  
  ### add new columns from a list ###
  columns_list  = []
  for x in df['Custom Field']:
  ### create multiple columns with x ##
    columns_list.append(x)  
  ### convert list to new columns ###
  df2 = pd.DataFrame(df,columns=columns_list)
  df2[&quot;Name&quot;] = df[&quot;Name&quot;]
  print(df2)
  
  ### If Name df3 is equal to Name df and equal to Custom Field of df, then get the id of df   and insert the value into the corresponding column in df3. ###
  #### First unsuccessful attempt ###
  df2_columns_names = list(df2.columns.values)
  for df2_name in df2['Name']:
    for df2_cf in df2_columns_names:
      for df_name in df['Name']:
        for df_cf in df['Custom Field']:
          for df_id in df['id']:
            if df2_name == df_name and df2_cf == df_cf:
              df2.loc[df2_name, df2_cf] = df_id
   print(df2)  
  </code></pre>
  <p>Any suggestions?</p>
  <p>Thanks in advance.</p>