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:
| dt         |   AverageTemperature |   AverageTemperatureUncertainty | Country              |
|:-----------|---------------------:|--------------------------------:|:---------------------|
| 1787-04-01 |                6.841 |                           3.438 | Netherlands (Europe) |
| 1894-08-01 |               18.873 |                           1.695 | New Caledonia        |
| 1751-03-01 |                6.942 |                           1.824 | Isle Of Man          |
| 1931-03-01 |               27.372 |                           0.421 | Aruba                |
| 1988-03-01 |               14.425 |                           0.258 | Israel               |
| 1971-06-01 |               17.662 |                           0.195 | China                |
| 1862-04-01 |               26.283 |                           1.236 | El Salvador          |
| 1972-07-01 |               27.412 |                           0.228 | Grenada              |
| 1833-12-01 |               10.086 |                           2.204 | Morocco              |
| 1885-11-01 |                6.159 |                           0.785 | Macedonia            |


Target Schema:
| Country             | AverageTemperature_x   | AverageTemperature_y   |
|:--------------------|:-----------------------|:-----------------------|
| Afghanistan         | 27.988000000000003     | -4.254                 |
| Africa              | 26.843000000000004     | 19.79                  |
| Albania             | 25.081                 | -2.0489999999999995    |
| Algeria             | 35.702                 | 10.059                 |
| American Samoa      | 28.243000000000002     | 24.833000000000002     |
| Andorra             | 22.885                 | -0.7469999999999994    |
| Angola              | 24.974                 | 17.607                 |
| Anguilla            | 29.346999999999998     | 23.876                 |
| Antarctica          |                        |                        |
| Antigua And Barbuda | 29.328000000000007     | 23.432                 |

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



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