Task: Transform-by-output-target-schema (source dataset: github-pipelines)

Your task is to create a data transformation pipeline in Python using pandas libraries.

Given Source Tables below, and a Target Schema provided by users that demonstrates how the desired output table should look like schematically, please write Python pandas code that can transform the Source Tables into an output table, that matches the schema/structure given by the Target Schema.  Please note that the data values in the Target Schema are intended to represent the format and layout of the output table, but may not exactly match the actual data generated from the Source Tables when the python code is run on the Source Tables.

Use operations such as merge, groupby, pivot, apply, or any appropriate python or pandas steps. Your code should save the resulting DataFrame to a CSV file named 'output.csv'. Ensure that the code is executable and can be run directly as is, in a Python environment with pandas installed.

Source Tables:


Table #1
Filename: source_0.csv
Sample Rows in Markdown:
|   CodProvincia | Provincia   |   CodMunicipio | Municipio             |   Poblacion |
|---------------:|:------------|---------------:|:----------------------|------------:|
|              1 | Araba/Álava |              1 | Alegría-Dulantzi      |        2869 |
|              1 | Araba/Álava |              2 | Amurrio               |       10114 |
|              1 | Araba/Álava |              3 | Aramaio               |        1513 |
|              1 | Araba/Álava |              4 | Artziniega            |        1861 |
|              1 | Araba/Álava |              6 | Armiñón               |         231 |
|              1 | Araba/Álava |              8 | Arrazua-Ubarrundia    |         983 |
|              1 | Araba/Álava |              9 | Asparrena             |        1698 |
|              1 | Araba/Álava |             10 | Ayala/Aiara           |        2918 |
|              1 | Araba/Álava |             11 | Baños de Ebro/Mañueta |         317 |
|              1 | Araba/Álava |             13 | Barrundia             |         908 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   CodProvincia |   CodMunicipio |    CP | Municipio   |
|---------------:|---------------:|------:|:------------|
|             27 |             28 | 27160 | Lugo        |
|             27 |             28 | 27161 | Lugo        |
|             27 |             28 | 27169 | Lugo        |
|             27 |             28 | 27180 | Lugo        |
|             27 |             28 | 27181 | Lugo        |
|             27 |             28 | 27182 | Lugo        |
|             27 |             28 | 27003 | Lugo        |
|             27 |             29 | 27240 | Meira       |
|             27 |             29 | 27241 | Meira       |
|             27 |             29 | 27247 | Meira       |


Target Schema:
|   CP |   Municipio |   SumPoblacion | Provincia   |
|-----:|------------:|---------------:|:------------|
|  548 |           1 |           5233 | Ávila       |
| 1001 |           1 |         242223 | Araba/Álava |
| 1002 |           1 |         242223 | Araba/Álava |
| 1003 |           1 |         242223 | Araba/Álava |
| 1004 |           1 |         242223 | Araba/Álava |
| 1005 |           1 |         242223 | Araba/Álava |
| 1006 |           1 |         242223 | Araba/Álava |
| 1007 |           1 |         242223 | Araba/Álava |
| 1008 |           1 |         242223 | Araba/Álava |
| 1009 |           1 |         242223 | Araba/Álava |

Return only the final code in markdown codeblock format, without any additional text or explanation. 



target: target.csv
train: source_0.csv
source_1.csv
test: test_0.csv
test_1.csv