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 | Kandahar    | Kandahar   | Fuel (diesel)                                 | AFN        | Retail    |      15 | L         |          1 |      2004 |     14.4   |
| Afghanistan | Balkh       | Mazar      | Bread                                         | AFN        | Retail    |       5 | KG        |          5 |      2016 |     50     |
| Afghanistan | Faryab      | Maymana    | Wage (qualified labour)                       | AFN        | Retail    |      51 | Day       |          7 |      2014 |    700     |
| Afghanistan | Badakhshan  | Fayzabad   | Wage (non-qualified labour, non-agricultural) | AFN        | Retail    |      51 | Day       |          8 |      2015 |    300     |
| Afghanistan | $Daykundi   | Nili       | Bread                                         | AFN        | Retail    |       5 | KG        |          8 |      2017 |     51.72  |
| Afghanistan | Badakhshan  | Fayzabad   | Wheat                                         | AFN        | Retail    |       5 | KG        |          4 |      2015 |     25     |
| Afghanistan | Faryab      | Maymana    | Wheat                                         | AFN        | Retail    |       5 | KG        |          5 |      2004 |      6.9   |
| Afghanistan | Nangarhar   | Jalalabad  | Wheat                                         | AFN        | Retail    |       5 | KG        |          1 |      2007 |     11.9   |
| Afghanistan | Badakhshan  | Fayzabad   | Exchange rate                                 | AFN        | Retail    |      56 | USD/LCU   |          3 |      2016 |     68.275 |
| Afghanistan | Nangarhar   | Jalalabad  | Bread                                         | AFN        | Retail    |       5 | KG        |         10 |      2017 |     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        | Salah al-Din | Salhdin    | Bread (khoboz)  | IQD        | Retail    |      33 | Unit      |          7 |      2012 |        100 |
| Iraq        | Kirkuk       | Kerkuk     | Rice            | IQD        | Retail    |       5 | KG        |          7 |      2013 |       2146 |
| Iraq        | Babil        | Babylon    | Wheat flour     | IQD        | Retail    |       5 | KG        |          4 |      2014 |        500 |
| Iraq        | Erbil        | Erbil      | Oil (vegetable) | IQD        | Retail    |      15 | L         |         10 |      2013 |       2375 |
| Iraq        | Kirkuk       | Kerkuk     | Bread (khoboz)  | IQD        | Retail    |      33 | Unit      |         11 |      2016 |        250 |
| Iraq        | Najaf        | Najaf      | Wheat flour     | IQD        | Retail    |       5 | KG        |          5 |      2014 |        500 |
| Iraq        | Qadissiya    | Wasit      | Bread (khoboz)  | IQD        | Retail    |      33 | Unit      |          2 |      2016 |        167 |
| Iraq        | Baghdad      | Baghdad    | Oil (vegetable) | IQD        | Retail    |      15 | L         |         10 |      2015 |       2000 |
| Iraq        | Missan       | Missan     | Wheat flour     | IQD        | Retail    |       5 | KG        |          1 |      2013 |        500 |
| Iraq        | Erbil        | Erbil      | Wheat flour     | IQD        | Retail    |       5 | KG        |          1 |      2013 |        500 |


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 |
|:------------|:--------------------|:-----------|:-----------------------|:-----------|:----------|--------:|:----------|-----------:|----------:|-----------:|
| Pakistan    | Punjab              | Lahore     | Fuel (diesel)          | PKR        | Retail    |      15 | L         |          5 |      2016 |      72.88 |
| Pakistan    | North-West Frontier | Peshawar   | Fuel (petrol-gasoline) | PKR        | Retail    |      15 | L         |          7 |      2017 |      71.57 |
| Pakistan    | Sindh               | Karachi    | Salt                   | PKR        | Retail    |       5 | KG        |          2 |      2016 |      12    |
| Pakistan    | Punjab              | Multan     | Milk                   | PKR        | Retail    |      15 | L         |          5 |      2017 |      78.33 |
| Pakistan    | Punjab              | Multan     | Wheat flour            | PKR        | Retail    |       5 | KG        |         10 |      2015 |      38.5  |
| Pakistan    | Balochistan         | Quetta     | Rice (basmati, broken) | PKR        | Retail    |       5 | KG        |          4 |      2010 |      50    |
| Pakistan    | Balochistan         | Quetta     | Wheat                  | PKR        | Retail    |       5 | KG        |          2 |      2015 |      38.5  |
| Pakistan    | Sindh               | Karachi    | Rice (basmati, broken) | PKR        | Retail    |       5 | KG        |          5 |      2011 |      48.92 |
| Pakistan    | Punjab              | Lahore     | Beans(mash)            | PKR        | Retail    |       5 | KG        |         11 |      2014 |     177.01 |
| Pakistan    | North-West Frontier | Peshawar   | Rice (basmati, broken) | PKR        | Retail    |       5 | KG        |         10 |      2015 |      68.33 |


Table #4
Filename: source_3.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 |
|:------------|:------------|:-----------|:--------------------------|:-----------|:----------|--------:|:----------|-----------:|----------:|-----------:|
| Lebanon     | Bekaa       | West Beqaa | Bread (pita)              | LBP        | Retail    |       5 | KG        |         11 |      2015 |    1447.37 |
| Lebanon     | Bekaa       | Rashaya    | Cabbage                   | LBP        | Retail    |       5 | KG        |         12 |      2016 |    1000    |
| Lebanon     | Bekaa       | Zahle      | Fish (sardine, canned)    | LBP        | Retail    |       5 | KG        |         11 |      2013 |    9142.86 |
| Lebanon     | Beirut      | Keserwan   | Wheat flour               | LBP        | Retail    |      87 | 5 KG      |         12 |      2015 |    6500    |
| Lebanon     | South       | Sour       | Sugar                     | LBP        | Retail    |       5 | KG        |         12 |      2012 |    1955.2  |
| Lebanon     | Nabatiye    | Marjayoun  | Meat (beef, canned)       | LBP        | Retail    |      63 | 200 G     |          8 |      2014 |    1680    |
| Lebanon     | Bekaa       | Zahle      | Pasta                     | LBP        | Retail    |       5 | KG        |         10 |      2016 |    2125    |
| Lebanon     | Bekaa       | Zahle      | Cheese (picon)            | LBP        | Retail    |      65 | 160 G     |         11 |      2013 |    1985.71 |
| Lebanon     | Nabatiye    | Nabatiyeh  | Rice (imported, Egyptian) | LBP        | Retail    |       5 | KG        |          3 |      2015 |    1899.9  |
| Lebanon     | Bekaa       | Hermel     | Milk (powder)             | LBP        | Retail    |       5 | KG        |          7 |      2013 |   12708.3  |


Table #5
Filename: source_4.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   |
|-------------|-------------|------------|-----------|------------|-----------|---------|-----------|------------|-----------|------------|


Table #6
Filename: source_5.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 |
|:-------------------|:-------------------|:-----------|:------------------------|:-----------|:----------|--------:|:----------|-----------:|----------:|-----------:|
| State of Palestine | Tulkarm            | Tulkarem   | Bread                   | NIS        | Retail    |       5 | KG        |          5 |      2016 |     4      |
| State of Palestine | Rafah              | Rafah      | Fish (red snapper)      | NIS        | Retail    |       5 | KG        |          6 |      2017 |    25      |
| State of Palestine | Al Khalil (Hebron) | Hebron     | Bread                   | NIS        | Retail    |       5 | KG        |          6 |      2017 |     3.5    |
| State of Palestine | Rafah              | Rafah      | Labaneh                 | NIS        | Retail    |      28 | 500 G     |          1 |      2017 |     8      |
| State of Palestine | Rafah              | Rafah      | Meat (goat, with bones) | NIS        | Retail    |       5 | KG        |         10 |      2017 |    52.5    |
| State of Palestine | Bethlehem          | Bethlehem  | Tea                     | NIS        | Retail    |       5 | KG        |          1 |      2017 |    15.3333 |
| State of Palestine | Nablus             | Nablus     | Meat (beef)             | NIS        | Retail    |       5 | KG        |          4 |      2017 |    49      |
| State of Palestine | Jabalya            | Gaza North | Meat (beef)             | NIS        | Retail    |       5 | KG        |         10 |      2017 |    46      |
| State of Palestine | Nablus             | Nablus     | Eggs                    | NIS        | Retail    |      57 | 2 KG      |          9 |      2017 |    15.25   |
| State of Palestine | Rafah              | Rafah      | Salt                    | NIS        | Retail    |       5 | KG        |          1 |      2017 |     1.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 |    Year |
|:------------|:------------|:-----------|:----------------------------------------------|:-----------|:----------|--------:|:----------|-----------:|----------:|-----------:|--------:|
| Afghanistan | Kandahar    | Kandahar   | Fuel (diesel)                                 | AFN        | Retail    |      15 | L         |          1 |      2004 |     14.4   | 2004    |
| Afghanistan | Balkh       | Mazar      | Bread                                         | AFN        | Retail    |       5 | KG        |          5 |      2016 |     50     | 2016.33 |
| Afghanistan | Faryab      | Maymana    | Wage (qualified labour)                       | AFN        | Retail    |      51 | Day       |          7 |      2014 |    700     | 2014.5  |
| Afghanistan | Badakhshan  | Fayzabad   | Wage (non-qualified labour, non-agricultural) | AFN        | Retail    |      51 | Day       |          8 |      2015 |    300     | 2015.58 |
| Afghanistan | $Daykundi   | Nili       | Bread                                         | AFN        | Retail    |       5 | KG        |          8 |      2017 |     51.72  | 2017.58 |
| Afghanistan | Badakhshan  | Fayzabad   | Wheat                                         | AFN        | Retail    |       5 | KG        |          4 |      2015 |     25     | 2015.25 |
| Afghanistan | Faryab      | Maymana    | Wheat                                         | AFN        | Retail    |       5 | KG        |          5 |      2004 |      6.9   | 2004.33 |
| Afghanistan | Nangarhar   | Jalalabad  | Wheat                                         | AFN        | Retail    |       5 | KG        |          1 |      2007 |     11.9   | 2007    |
| Afghanistan | Badakhshan  | Fayzabad   | Exchange rate                                 | AFN        | Retail    |      56 | USD/LCU   |          3 |      2016 |     68.275 | 2016.17 |
| Afghanistan | Nangarhar   | Jalalabad  | Bread                                         | AFN        | Retail    |       5 | KG        |         10 |      2017 |     50     | 2017.75 |

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
source_3.csv
source_4.csv
source_5.csv
test: test_0.csv
test_1.csv
test_2.csv
test_3.csv
test_4.csv
test_5.csv