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:
| adm0_name   | adm1_name   | mkt_name   | cm_name   | cur_name   | pt_name   |   um_id | um_name   |   mp_month |   mp_year |   mp_price |
|:------------|:------------|:-----------|:----------|:-----------|:----------|--------:|:----------|-----------:|----------:|-----------:|
| Afghanistan | Badakhshan  | Fayzabad   | Bread     | AFN        | Retail    |       5 | KG        |          1 |      2014 |         50 |
| Afghanistan | Badakhshan  | Fayzabad   | Bread     | AFN        | Retail    |       5 | KG        |          2 |      2014 |         50 |
| Afghanistan | Badakhshan  | Fayzabad   | Bread     | AFN        | Retail    |       5 | KG        |          3 |      2014 |         50 |
| Afghanistan | Badakhshan  | Fayzabad   | Bread     | AFN        | Retail    |       5 | KG        |          4 |      2014 |         50 |
| Afghanistan | Badakhshan  | Fayzabad   | Bread     | AFN        | Retail    |       5 | KG        |          5 |      2014 |         50 |
| Afghanistan | Badakhshan  | Fayzabad   | Bread     | AFN        | Retail    |       5 | KG        |          6 |      2014 |         50 |
| Afghanistan | Badakhshan  | Fayzabad   | Bread     | AFN        | Retail    |       5 | KG        |          7 |      2014 |         50 |
| Afghanistan | Badakhshan  | Fayzabad   | Bread     | AFN        | Retail    |       5 | KG        |          8 |      2014 |         50 |
| Afghanistan | Badakhshan  | Fayzabad   | Bread     | AFN        | Retail    |       5 | KG        |          9 |      2014 |         50 |
| Afghanistan | Badakhshan  | Fayzabad   | Bread     | AFN        | Retail    |       5 | KG        |         10 |      2014 |         50 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| adm0_name   | adm1_name   | mkt_name   | cm_name   | cur_name   | pt_name   |   um_id | um_name   |   mp_month |   mp_year |   mp_price |
|:------------|:------------|:-----------|:----------|:-----------|:----------|--------:|:----------|-----------:|----------:|-----------:|
| Iraq        | Anbar       | Alanbar    | Rice      | IQD        | Retail    |       5 | KG        |          1 |      2012 |       1496 |
| Iraq        | Anbar       | Alanbar    | Rice      | IQD        | Retail    |       5 | KG        |          2 |      2012 |       1496 |
| Iraq        | Anbar       | Alanbar    | Rice      | IQD        | Retail    |       5 | KG        |          3 |      2012 |       1542 |
| Iraq        | Anbar       | Alanbar    | Rice      | IQD        | Retail    |       5 | KG        |          4 |      2012 |       1542 |
| Iraq        | Anbar       | Alanbar    | Rice      | IQD        | Retail    |       5 | KG        |          5 |      2012 |       1542 |
| Iraq        | Anbar       | Alanbar    | Rice      | IQD        | Retail    |       5 | KG        |          6 |      2012 |       1542 |
| Iraq        | Anbar       | Alanbar    | Rice      | IQD        | Retail    |       5 | KG        |          7 |      2012 |       1567 |
| Iraq        | Anbar       | Alanbar    | Rice      | IQD        | Retail    |       5 | KG        |          8 |      2012 |       1567 |
| Iraq        | Anbar       | Alanbar    | Rice      | IQD        | Retail    |       5 | KG        |          9 |      2012 |       1567 |
| Iraq        | Anbar       | Alanbar    | Rice      | IQD        | Retail    |       5 | KG        |         10 |      2012 |       1567 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| adm0_name   | adm1_name         | mkt_name    | cm_name              | cur_name   | pt_name   |   um_id | um_name   |   mp_month |   mp_year |   mp_price |
|:------------|:------------------|:------------|:---------------------|:-----------|:----------|--------:|:----------|-----------:|----------:|-----------:|
| South Sudan | Central Equatoria | Konyo Konyo | Groundnuts (shelled) | SSP        | Retail    |       5 | KG        |          2 |      2017 |      212   |
| South Sudan | Central Equatoria | Konyo Konyo | Groundnuts (shelled) | SSP        | Retail    |       5 | KG        |          3 |      2017 |      250   |
| South Sudan | Central Equatoria | Konyo Konyo | Groundnuts (shelled) | SSP        | Retail    |       5 | KG        |          4 |      2017 |      265   |
| South Sudan | Central Equatoria | Konyo Konyo | Groundnuts (shelled) | SSP        | Retail    |       5 | KG        |          5 |      2017 |      260   |
| South Sudan | Central Equatoria | Konyo Konyo | Groundnuts (shelled) | SSP        | Retail    |       5 | KG        |          6 |      2017 |      263   |
| South Sudan | Central Equatoria | Konyo Konyo | Groundnuts (shelled) | SSP        | Retail    |       5 | KG        |          7 |      2017 |      225   |
| South Sudan | Central Equatoria | Konyo Konyo | Groundnuts (shelled) | SSP        | Retail    |       5 | KG        |          8 |      2017 |      250   |
| South Sudan | Central Equatoria | Konyo Konyo | Groundnuts (shelled) | SSP        | Retail    |       5 | KG        |         10 |      2017 |      360   |
| South Sudan | Central Equatoria | Konyo Konyo | Sorghum (white)      | SSP        | Retail    |      47 | 3.5 KG    |          1 |      2006 |        4.5 |
| South Sudan | Central Equatoria | Konyo Konyo | Sorghum (white)      | SSP        | Retail    |      47 | 3.5 KG    |          2 |      2006 |        4.5 |


Target Schema:
| adm0_name   | adm1_name   | mkt_name         | cm_name       | cur_name   | pt_name   |   um_id | um_name   |   mp_month |   mp_year |   mp_price |
|:------------|:------------|:-----------------|:--------------|:-----------|:----------|--------:|:----------|-----------:|----------:|-----------:|
| South Sudan |             | National Average | Fuel (diesel) | SSP        | Retail    |      15 | L         |          1 |      2012 |     7.9063 |
| South Sudan |             | National Average | Fuel (diesel) | SSP        | Retail    |      15 | L         |          2 |      2012 |     7.275  |
| South Sudan |             | National Average | Fuel (diesel) | SSP        | Retail    |      15 | L         |          3 |      2012 |     7.4531 |
| South Sudan |             | National Average | Fuel (diesel) | SSP        | Retail    |      15 | L         |          4 |      2012 |     8.1719 |
| South Sudan |             | National Average | Fuel (diesel) | SSP        | Retail    |      15 | L         |          5 |      2012 |    11.9688 |
| South Sudan |             | National Average | Fuel (diesel) | SSP        | Retail    |      15 | L         |          6 |      2012 |    10.2656 |
| South Sudan |             | National Average | Fuel (diesel) | SSP        | Retail    |      15 | L         |          7 |      2012 |    10.3438 |
| South Sudan |             | National Average | Fuel (diesel) | SSP        | Retail    |      15 | L         |          8 |      2012 |    10.8125 |
| South Sudan |             | National Average | Fuel (diesel) | SSP        | Retail    |      15 | L         |          9 |      2012 |    10.125  |
| South Sudan |             | National Average | Fuel (diesel) | SSP        | Retail    |      15 | L         |         10 |      2012 |    10.6875 |

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
source_2.csv
test: test_0.csv
test_1.csv
test_2.csv