Question: I have two DataFrame A and B as-

```
table_a = pd.DataFrame({
    'unique_id':[3823762,3976695,4199277,4201777,4202712],
    'full_name':['A','B','C','D','E'],
    'freq_match_it':[np.NaN,np.NaN,np.NaN,np.NaN,np.NaN],
    'address':['hyd','jgl','krmr','wl','ktk']
})

```

```
table_b = pd.DataFrame({
    'unique_id':[419434,4201777,784744,4202712,10000],
    'freq_match_it':[12,15,8,5,100]

})

```

Here I would like to fill in `freq_match_it` column in `table_a` whose `unique_id`s exist in `table_b` using a left join in pandas as

```
pd.merge(table_a,table_b,how='left',on='unique_id')

```

it shows as-

[![enter image description here](https://i.stack.imgur.com/It0OP.png)](https://i.stack.imgur.com/It0OP.png)

Here it has created an extra column `freq_match_it_y` and I want to fill in the already existing column `freq_match_it` rather than create an additional column.

The expected output is

[![enter image description here](https://i.stack.imgur.com/gXs1b.png)](https://i.stack.imgur.com/gXs1b.png)

Answer: 
> 
> I think inside function, the passed argument is assigned to function parameter
> 
> 
> 

No. The arguments are essentially local variables of the called function, *except they are created by the caller before* the execution goes into the function. The function does not even know how they were constructed.

> 
> why does function use copy constructor?
> 
> 
> 

So this assumption is wrong, the function does not use copy constructor on its arguments. *The caller does* (if argument is a variable and passed by value, so copy needs to be made).
> 
> How can function knows that function have to use copy constructor?
> 
> 
> 

When passing the argument by value, the **parameter** is **initialized** by the passed argument. And from [copy constructor's documentation](https://en.cppreference.com/w/cpp/language/copy_constructor):

> 
> The copy constructor is called whenever an object is **initialized** (by direct-initialization or copy-initialization) from another object of the same type (unless overload resolution selects a better match or the call is elided), which includes :
> 
> 
> 

> 
> * **function argument passing**: `f(a);`, where `a` is of type `T` and `f` is `void f(T t);`
> 
> 
> 

So, since the passed argument is used to initialize the parameter(in case of pass by value), according to the above quoted statement, the copy constructor will be used.

---

Do note that in C++, **assignment** and **initialization** are different.

---

Additionally, note that **move constructor** can also be used instead of copy constructor in case the argument is an `rvalue`. From [move constructor's documentation](https://en.cppreference.com/w/cpp/language/move_constructor):

> 
> The move constructor is typically called when an object is **initialized** (by direct-initialization or copy-initialization) from rvalue (xvalue or prvalue) (until C++17)xvalue (since C++17) of the same type, including
> 
> 
> 

> 
> * **function argument passing**: `f(std::move(a));`, where `a` is of type `T` and `f` is `void f(T t);`
> 
> 
>