title: merging two dataframes and reducing the number of columns
body: <p>I have two dataframes, df_dates, df_ratios. Both dataframes have the same dimensions 150 x 4. The both have a column which is a security id and this column is the same in both dataframes.</p>
  
  <pre><code>df_dates
  id     col1       col2       col3        col4
  1sds   nan        nan        20200108    nan
  bhu6   20190404   nan        nan         nan
  lm55   nan        nan        20200623    20201215
  bn34   nan        nan        nan         nan
  
  
  df_ratios
  id     col1       col2       col3        col4
  1sds   nan        nan        1.34        nan
  bhu6   2.6        nan        nan         nan
  lm55   nan        nan        0.23        0.45
  bn34   nan        nan        nan         nan
  </code></pre>
  
  <p>What I need is shown below. Basically where there is a date in df_dates there will be a corresponding number in df_ratios &amp; I want to align them together &amp; any nan's to be ignored. The only way I know how to solve this problem is to simply loop through each row and column in the dataframes and apply some simple logic. I was wondering if there is a more efficient way of doing this in pandas?</p>
  
  <pre><code>df_result
  id     dates      ratios
  1sds   20200108   1.34
  bhu6   20190404   2.6
  lm55   20200623   0.23        
  lm55   20201215   0.45       
  </code></pre>