How to concat and update pandas dataframes
<p>I'd like to concat the dataframe <strong>df1</strong> and <strong>df2</strong> and result the dataframe <strong>df</strong></p>

<pre><code>df1 = pd.DataFrame([
    {"id": 1, "a": 1, "b": 1},
    {"id": 2, "a": 2, "b": 2},
])

df2 = pd.DataFrame([
    {"id": 1, "a": 5, "b": 5},
    {"id": 3, "a": 6, "b": 6}
])

df = pd.DataFrame([
    {"id": 1, "a": 5, "b": 5},
    {"id": 2, "a": 2, "b": 2},
    {"id": 3, "a": 6, "b": 6}
])
</code></pre>

<p>As can see, the row of same <strong>id</strong> are updated.</p>

<ol>
<li>Concatenate</li>
<li>Remove duplicates</li>
</ol>

<hr>

<pre><code>df1 = pd.DataFrame([
    {"id": 1, "a": 1, "b": 1},
    {"id": 2, "a": 2, "b": 2},
])

df2 = pd.DataFrame([
    {"id": 1, "a": 5, "b": 5},
    {"id": 3, "a": 6, "b": 6}
])

print (pd.concat([df1.set_index('id'),
                  df2.set_index('id')])
       .reset_index()
       .drop_duplicates(subset='id', keep='last')
       .set_index('id')
       .sort_index())
</code></pre>

<hr>

<p>Output:</p>

<pre><code>    a  b
id      
1   5  5
2   2  2
3   6  6
</code></pre>

python pandas