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             | Code   |       Population | GDP per Capita     |
|:--------------------|:-------|-----------------:|:-------------------|
| Afghanistan         | AFG    |      3.25266e+07 | 594.323081219966   |
| Albania             | ALB    |      2.88917e+06 | 3945.21758150914   |
| Algeria             | ALG    |      3.96665e+07 | 4206.03123244958   |
| American Samoa*     | ASA    |  55538           |                    |
| Andorra             | AND    |  70473           |                    |
| Angola              | ANG    |      2.5022e+07  | 4101.47215182964   |
| Antigua and Barbuda | ANT    |  91818           | 13714.731961698799 |
| Argentina           | ARG    |      4.34168e+07 | 13431.8783398577   |
| Armenia             | ARM    |      3.01771e+06 | 3489.12768956995   |
| Aruba*              | ARU    | 103889           |                    |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   Year | City        | Sport      | Discipline   | Athlete           | Country   | Gender   | Event      | Medal   |
|-------:|:------------|:-----------|:-------------|:------------------|:----------|:---------|:-----------|:--------|
|   1994 | Lillehammer | Ice Hockey | Ice Hockey   | KAPANEN, Sami     | FIN       | Men      | Ice Hockey | Bronze  |
|   1994 | Lillehammer | Ice Hockey | Ice Hockey   | KESKINEN, Esa     | FIN       | Men      | Ice Hockey | Bronze  |
|   1994 | Lillehammer | Ice Hockey | Ice Hockey   | KIPRUSOFF, Marko  | FIN       | Men      | Ice Hockey | Bronze  |
|   1994 | Lillehammer | Ice Hockey | Ice Hockey   | KOIVU, Saku       | FIN       | Men      | Ice Hockey | Bronze  |
|   1994 | Lillehammer | Ice Hockey | Ice Hockey   | KUIVALAINEN, Pasi | FIN       | Men      | Ice Hockey | Bronze  |
|   1994 | Lillehammer | Ice Hockey | Ice Hockey   | LAUKKANEN, Janne  | FIN       | Men      | Ice Hockey | Bronze  |
|   1994 | Lillehammer | Ice Hockey | Ice Hockey   | LEHTERAE, Tero    | FIN       | Men      | Ice Hockey | Bronze  |
|   1994 | Lillehammer | Ice Hockey | Ice Hockey   | LEHTINEN, Jere    | FIN       | Men      | Ice Hockey | Bronze  |
|   1994 | Lillehammer | Ice Hockey | Ice Hockey   | MÄKELÄ, Mikko     | FIN       | Men      | Ice Hockey | Bronze  |
|   1994 | Lillehammer | Ice Hockey | Ice Hockey   | MYLLYS, Jarmo     | FIN       | Men      | Ice Hockey | Bronze  |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| Host City   | Host          |   Year |
|:------------|:--------------|-------:|
| Paris       | France        |   1924 |
| Bern        | Switzerland   |   1928 |
| Albany      | United States |   1932 |
| Berlin      | Germany       |   1936 |
| Tokyo       | Japan         |   1940 |
| Rome        | Italy         |   1944 |
| Bern        | Switzerland   |   1948 |
| Oslo        | Norway        |   1952 |
| Rome        | Italy         |   1956 |
| Chicago     | United States |   1960 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
| Host City   |       Date |   Latitude |   Longitude |   Temperature |   Humidity |   Wind speed |   Cloudliness |
|:------------|-----------:|-----------:|------------:|--------------:|-----------:|-------------:|--------------:|
| Paris       | 1594997280 |      48.85 |        2.35 |         80.01 |         49 |         6.93 |            40 |
| Bern        | 1594997474 |      46.95 |        7.45 |         69.01 |         63 |         5.82 |            90 |
| Albany      | 1594997474 |      42.6  |      -73.97 |         73.99 |         77 |         6.98 |            93 |
| Berlin      | 1594997403 |      52.52 |       13.41 |         70    |         82 |         3.36 |            75 |
| Tokyo       | 1594997396 |      35.69 |      139.69 |         68    |        100 |         9.17 |            75 |
| Rome        | 1594997208 |      34.26 |      -85.16 |         87.01 |         66 |         1.1  |             1 |
| Bern        | 1594997474 |      46.95 |        7.45 |         69.01 |         63 |         5.82 |            90 |
| Oslo        | 1594997201 |      59.91 |       10.75 |         70    |         70 |         3    |           100 |
| Rome        | 1594997208 |      34.26 |      -85.16 |         87.01 |         66 |         1.1  |             1 |
| Chicago     | 1594997270 |      41.85 |      -87.65 |         82.99 |         69 |         9.17 |            20 |


Target Schema:
| Country   |   Population |   Medal |   Latitude |
|:----------|-------------:|--------:|-----------:|
| Austria   |      8611088 |     109 |    44.8207 |
| Belgium   |     11285721 |      19 |    47.45   |
| Bulgaria  |      7177991 |       1 |    42.6    |
| Canada    |     35851774 |     196 |    44.9221 |
| Finland   |      5482013 |     145 |    45.6234 |
| France    |     66808385 |      42 |    47.3181 |
| Germany   |     81413145 |      38 |    45.5721 |
| Hungary   |      9844686 |      16 |    45.0063 |
| Italy     |     60802085 |      38 |    41.9255 |
| Japan     |    126958472 |       3 |    37.04   |

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