python pandas How to copy column values regarding an index column
<p><em>Note: the question was edited and extended as it originally lacked precision.
The first example introduces the question, but should only be considered as an introduction</em></p>

<p>Having two datasets looking like:</p>

<pre><code>idx  value other_columns  
1    7  
2    6  
3    5  

idx  value ...other_columns  
1    0  
2    0  
4    0  
</code></pre>

<p>I'd like to copy the fist dataset values regarding the index column (and set NaN on non matching columns)</p>

<p>Obtaining this:  </p>

<pre><code>idx  value ...other_columns  
1    7  
2    6  
4    NaN
</code></pre>

<p>Regards  </p>

<p>Edit:</p>

<p>Regarding my initial post, EdChum's answer was correct, but my question lacked precision.</p>

<p>The other_columns means i'd like to keep the other columns unchanged, an my goal is inserting values from dataset1 in dataset2.
More precise example:</p>

<pre><code>df1= pd.DataFrame({'idx':[1,2,3], 'val':[7,6,5], 'other':[1,1,1]})  
df2= pd.DataFrame({'idx':[1,2,4], 'val':[0,0,0], 'other':[1,1,1]})  

 df1  
   idx  other val  
0    1      1   7  
1    2      1   6  
2    3      1   5  

 df2  
   idx  other  val  
0    1      7    0  
1    2      7    0  
2    4      7    0  
</code></pre>

<p>I'd like to retrieve </p>

<pre><code>   idx  other  val  
0    1      7    7  
1    2      7    6  
2    4      7    NaN  
</code></pre>

<p>Which is a sub frame from Fuego's merge based anwser, but i don't see yet how to only keep the ['idx','val_x','other_y'] cols.</p>