title: Python: How To create new data-frame with 2 data-frames that datas from one of those two have to be replaced by other's column name
body: <p>All I want to do is to create a stocks' decile frame by industry factor model.</p>
  <p>So far, I've made a decile frame based on industry's factor named as zongmok</p>
  <p><a href="https://i.stack.imgur.com/qP9Yg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qP9Yg.png" alt="zongmok" /></a></p>
  <p>And a frame called inds that shows information about which industry does stock belong to.</p>
  <p><a href="https://i.stack.imgur.com/ANHgv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ANHgv.png" alt="inds" /></a></p>
  <p>The problem is that how to create a new data frame to show each stock's decile based on industry factor at every index time. (The new data frame is called df, and I've tried to use squared for loop, But It was too slow to complete the whole task.)</p>
  <p><a href="https://i.stack.imgur.com/0olNt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0olNt.png" alt="df" /></a></p>
  <p>Here's the code I've tried:</p>
  <pre class="lang-py prettyprint-override"><code>for i in notebook.tqdm(range(len(df))):
      for j in notebook.tqdm(range(len(df.columns))):
          try:
              df[df.columns[j]].loc[df.index[i]] = zongmok[inds.loc[df.index][inds == zongmok.columns[j]].dropna(axis=1)[inds[inds == zongmok.columns[j]].dropna(axis=1).columns[j]].loc[df.index[i]]].loc[df.index[i]]
          except Exception:
              pass
          else:
              pass
  </code></pre>