I have the following Dataframes:
Dataframe 1:
|---------------------|------------------|
| property_id | beds |
|---------------------|------------------|
| 1 | 1 |
|---------------------|------------------|
| 2 | 2 |
|---------------------|------------------|
Dataframe 2:
|---------------------|
| property_id |
|---------------------|
| 3 |
|---------------------|
| 4 |
|---------------------|
What I want to produce is the following Dataframe:
|---------------------|------------------|
| property_id | beds |
|---------------------|------------------|
| 1 | 1 |
|---------------------|------------------|
| 2 | 2 |
|---------------------|------------------|
| 3 | 0 |
|---------------------|------------------|
| 4 | 0 |
|---------------------|------------------|
What I want is to concatenate two Dataframes, and the former has more columns than the latter, but all the columns of the latter are in the former. When the column is not present in the latter dataframe I want to set a default value of 0. How can I achieve this?
df1 = pd.DataFrame({'property_id': [1, 2], 'beds': [1, 2]})
df2 = pd.DataFrame({'property_id': [3, 4]})
I have almost no experience with pandas, so what could I do?