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:
| Country     |   Happiness_Rank_17 |   Happiness_Score_17 |   Whisker_High_17 |   Whisker_Low_17 |   Economy_17 |   Family_17 |   Life_Expectancy_17 |   Freedom_17 |   Generosity_17 |   Trust_17 |   Dystopia_17 |
|:------------|--------------------:|---------------------:|------------------:|-----------------:|-------------:|------------:|---------------------:|-------------:|----------------:|-----------:|--------------:|
| Norway      |                   1 |                7.537 |           7.59444 |          7.47956 |      1.61646 |     1.53352 |             0.796667 |     0.635423 |        0.362012 |   0.315964 |       2.27703 |
| Denmark     |                   2 |                7.522 |           7.58173 |          7.46227 |      1.48238 |     1.55112 |             0.792566 |     0.626007 |        0.35528  |   0.40077  |       2.31371 |
| Iceland     |                   3 |                7.504 |           7.62203 |          7.38597 |      1.48063 |     1.61057 |             0.833552 |     0.627163 |        0.47554  |   0.153527 |       2.32272 |
| Switzerland |                   4 |                7.494 |           7.56177 |          7.42623 |      1.56498 |     1.51691 |             0.858131 |     0.620071 |        0.290549 |   0.367007 |       2.27672 |
| Finland     |                   5 |                7.469 |           7.52754 |          7.41046 |      1.44357 |     1.54025 |             0.809158 |     0.617951 |        0.245483 |   0.382612 |       2.43018 |
| Netherlands |                   6 |                7.377 |           7.42743 |          7.32657 |      1.50394 |     1.42894 |             0.810696 |     0.585384 |        0.47049  |   0.282662 |       2.2948  |
| Canada      |                   7 |                7.316 |           7.3844  |          7.2476  |      1.4792  |     1.48135 |             0.834558 |     0.611101 |        0.43554  |   0.287372 |       2.18726 |
| New Zealand |                   8 |                7.314 |           7.37951 |          7.24849 |      1.40571 |     1.5482  |             0.81676  |     0.614062 |        0.500005 |   0.382817 |       2.04646 |
| Sweden      |                   9 |                7.284 |           7.34409 |          7.2239  |      1.49439 |     1.47816 |             0.830875 |     0.612924 |        0.385399 |   0.384399 |       2.09754 |
| Australia   |                  10 |                7.284 |           7.35665 |          7.21135 |      1.48441 |     1.51004 |             0.843887 |     0.601607 |        0.477699 |   0.301184 |       2.06521 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| Country    | Region                          |   Happiness Rank |   Happiness Score |   Standard Error |   Economy (GDP per Capita) |   Family |   Health (Life Expectancy) |   Freedom |   Trust (Government Corruption) |   Generosity |   Dystopia Residual |
|:-----------|:--------------------------------|-----------------:|------------------:|-----------------:|---------------------------:|---------:|---------------------------:|----------:|--------------------------------:|-------------:|--------------------:|
| Azerbaijan | Central and Eastern Europe      |               80 |             5.212 |          0.03363 |                    1.02389 |  0.93793 |                    0.64045 |   0.3703  |                         0.16065 |      0.07799 |             2.00073 |
| Pakistan   | Southern Asia                   |               81 |             5.194 |          0.03726 |                    0.59543 |  0.41411 |                    0.51466 |   0.12102 |                         0.10464 |      0.33671 |             3.10709 |
| Jordan     | Middle East and Northern Africa |               82 |             5.192 |          0.04524 |                    0.90198 |  1.05392 |                    0.69639 |   0.40661 |                         0.14293 |      0.11053 |             1.87996 |
| Montenegro | Central and Eastern Europe      |               82 |             5.192 |          0.05235 |                    0.97438 |  0.90557 |                    0.72521 |   0.1826  |                         0.14296 |      0.1614  |             2.10017 |
| China      | Eastern Asia                    |               84 |             5.14  |          0.02424 |                    0.89012 |  0.94675 |                    0.81658 |   0.51697 |                         0.02781 |      0.08185 |             1.8604  |
| Zambia     | Sub-Saharan Africa              |               85 |             5.129 |          0.06988 |                    0.47038 |  0.91612 |                    0.29924 |   0.48827 |                         0.12468 |      0.19591 |             2.6343  |
| Romania    | Central and Eastern Europe      |               86 |             5.124 |          0.06607 |                    1.04345 |  0.88588 |                    0.7689  |   0.35068 |                         0.00649 |      0.13748 |             1.93129 |
| Serbia     | Central and Eastern Europe      |               87 |             5.123 |          0.04864 |                    0.92053 |  1.00964 |                    0.74836 |   0.20107 |                         0.02617 |      0.19231 |             2.025   |
| Portugal   | Western Europe                  |               88 |             5.102 |          0.04802 |                    1.15991 |  1.13935 |                    0.87519 |   0.51469 |                         0.01078 |      0.13719 |             1.26462 |
| Latvia     | Central and Eastern Europe      |               89 |             5.098 |          0.0464  |                    1.11312 |  1.09562 |                    0.72437 |   0.29671 |                         0.06332 |      0.18226 |             1.62215 |


Target Schema:
| Country     | Region                    |   Happiness_Rank_15 |   Happiness_Score_15 |   Standard_Error_15 |   Economy_15 |   Family_15 |   Life_Expectancy_15 |   Freedom_15 |   Trust_15 |   Generosity_15 |   Dystopia_15 |   Happiness_Rank_17 |   Happiness_Score_17 |   Whisker_High_17 |   Whisker_Low_17 |   Economy_17 |   Family_17 |   Life_Expectancy_17 |   Freedom_17 |   Generosity_17 |   Trust_17 |   Dystopia_17 |
|:------------|:--------------------------|--------------------:|---------------------:|--------------------:|-------------:|------------:|---------------------:|-------------:|-----------:|----------------:|--------------:|--------------------:|---------------------:|------------------:|-----------------:|-------------:|------------:|---------------------:|-------------:|----------------:|-----------:|--------------:|
| Switzerland | Western Europe            |                   1 |                7.587 |             0.03411 |      1.39651 |     1.34951 |              0.94143 |      0.66557 |    0.41978 |         0.29678 |       2.51738 |                   4 |                7.494 |           7.56177 |          7.42623 |      1.56498 |     1.51691 |             0.858131 |     0.620071 |        0.290549 |   0.367007 |       2.27672 |
| Iceland     | Western Europe            |                   2 |                7.561 |             0.04884 |      1.30232 |     1.40223 |              0.94784 |      0.62877 |    0.14145 |         0.4363  |       2.70201 |                   3 |                7.504 |           7.62203 |          7.38597 |      1.48063 |     1.61057 |             0.833552 |     0.627163 |        0.47554  |   0.153527 |       2.32272 |
| Denmark     | Western Europe            |                   3 |                7.527 |             0.03328 |      1.32548 |     1.36058 |              0.87464 |      0.64938 |    0.48357 |         0.34139 |       2.49204 |                   2 |                7.522 |           7.58173 |          7.46227 |      1.48238 |     1.55112 |             0.792566 |     0.626007 |        0.35528  |   0.40077  |       2.31371 |
| Norway      | Western Europe            |                   4 |                7.522 |             0.0388  |      1.459   |     1.33095 |              0.88521 |      0.66973 |    0.36503 |         0.34699 |       2.46531 |                   1 |                7.537 |           7.59444 |          7.47956 |      1.61646 |     1.53352 |             0.796667 |     0.635423 |        0.362012 |   0.315964 |       2.27703 |
| Canada      | North America             |                   5 |                7.427 |             0.03553 |      1.32629 |     1.32261 |              0.90563 |      0.63297 |    0.32957 |         0.45811 |       2.45176 |                   7 |                7.316 |           7.3844  |          7.2476  |      1.4792  |     1.48135 |             0.834558 |     0.611101 |        0.43554  |   0.287372 |       2.18726 |
| Finland     | Western Europe            |                   6 |                7.406 |             0.0314  |      1.29025 |     1.31826 |              0.88911 |      0.64169 |    0.41372 |         0.23351 |       2.61955 |                   5 |                7.469 |           7.52754 |          7.41046 |      1.44357 |     1.54025 |             0.809158 |     0.617951 |        0.245483 |   0.382612 |       2.43018 |
| Netherlands | Western Europe            |                   7 |                7.378 |             0.02799 |      1.32944 |     1.28017 |              0.89284 |      0.61576 |    0.31814 |         0.4761  |       2.4657  |                   6 |                7.377 |           7.42743 |          7.32657 |      1.50394 |     1.42894 |             0.810696 |     0.585384 |        0.47049  |   0.282662 |       2.2948  |
| Sweden      | Western Europe            |                   8 |                7.364 |             0.03157 |      1.33171 |     1.28907 |              0.91087 |      0.6598  |    0.43844 |         0.36262 |       2.37119 |                   9 |                7.284 |           7.34409 |          7.2239  |      1.49439 |     1.47816 |             0.830875 |     0.612924 |        0.385399 |   0.384399 |       2.09754 |
| New Zealand | Australia and New Zealand |                   9 |                7.286 |             0.03371 |      1.25018 |     1.31967 |              0.90837 |      0.63938 |    0.42922 |         0.47501 |       2.26425 |                   8 |                7.314 |           7.37951 |          7.24849 |      1.40571 |     1.5482  |             0.81676  |     0.614062 |        0.500005 |   0.382817 |       2.04646 |
| Australia   | Australia and New Zealand |                  10 |                7.284 |             0.04083 |      1.33358 |     1.30923 |              0.93156 |      0.65124 |    0.35637 |         0.43562 |       2.26646 |                  10 |                7.284 |           7.35665 |          7.21135 |      1.48441 |     1.51004 |             0.843887 |     0.601607 |        0.477699 |   0.301184 |       2.06521 |

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