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:
|   ID |   G1 |   G2 |   G3 |
|-----:|-----:|-----:|-----:|
|    0 |    5 |    6 |    6 |
|    1 |    5 |    5 |    6 |
|    2 |    7 |    8 |   10 |
|    3 |   15 |   14 |   15 |
|    4 |    6 |   10 |   10 |
|    5 |   15 |   15 |   15 |
|    6 |   12 |   12 |   11 |
|    7 |    6 |    5 |    6 |
|    8 |   16 |   18 |   19 |
|    9 |   14 |   15 |   15 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   ID | school   | sex   |   age | address   | famsize   | Pstatus   |   Medu |   Fedu | Mjob     | Fjob     | reason     | guardian   |   traveltime |   studytime |   failures | schoolsup   | famsup   | paid   | activities   | nursery   | higher   | internet   | romantic   |   famrel |   freetime |   goout |   Dalc |   Walc |   health |   absences |
|-----:|:---------|:------|------:|:----------|:----------|:----------|-------:|-------:|:---------|:---------|:-----------|:-----------|-------------:|------------:|-----------:|:------------|:---------|:-------|:-------------|:----------|:---------|:-----------|:-----------|---------:|-----------:|--------:|-------:|-------:|---------:|-----------:|
|  197 | GP       | M     |    16 | R         | LE3       | T         |      3 |      3 | teacher  | other    | home       | father     |            3 |           1 |          0 | no          | yes      | yes    | yes          | yes       | yes      | yes        | no         |        3 |          3 |       4 |      3 |      5 |        3 |          8 |
|  198 | GP       | F     |    17 | U         | GT3       | T         |      4 |      4 | services | teacher  | home       | mother     |            2 |           1 |          1 | no          | yes      | no     | no           | yes       | yes      | yes        | no         |        4 |          2 |       4 |      2 |      3 |        2 |         24 |
|  199 | GP       | F     |    16 | U         | LE3       | T         |      4 |      4 | teacher  | teacher  | reputation | mother     |            1 |           2 |          0 | no          | yes      | yes    | no           | yes       | yes      | yes        | no         |        4 |          5 |       2 |      1 |      2 |        3 |          0 |
|  200 | GP       | F     |    16 | U         | GT3       | T         |      4 |      3 | health   | other    | home       | mother     |            1 |           2 |          0 | no          | yes      | no     | yes          | yes       | yes      | yes        | no         |        4 |          3 |       5 |      1 |      5 |        2 |          2 |
|  201 | GP       | F     |    16 | U         | GT3       | T         |      2 |      3 | other    | other    | reputation | mother     |            1 |           2 |          0 | yes         | yes      | yes    | yes          | yes       | yes      | no         | no         |        4 |          4 |       3 |      1 |      3 |        4 |          6 |
|  202 | GP       | F     |    17 | U         | GT3       | T         |      1 |      1 | other    | other    | course     | mother     |            1 |           2 |          0 | no          | yes      | yes    | no           | no        | yes      | no         | no         |        4 |          4 |       4 |      1 |      3 |        1 |          4 |
|  203 | GP       | F     |    17 | R         | GT3       | T         |      2 |      2 | other    | other    | reputation | mother     |            1 |           1 |          0 | no          | yes      | no     | no           | yes       | yes      | yes        | no         |        5 |          3 |       2 |      1 |      2 |        3 |         18 |
|  204 | GP       | F     |    16 | R         | GT3       | T         |      2 |      2 | services | services | reputation | mother     |            2 |           4 |          0 | no          | yes      | yes    | yes          | no        | yes      | yes        | no         |        5 |          3 |       5 |      1 |      1 |        5 |          6 |
|  205 | GP       | F     |    17 | U         | GT3       | T         |      3 |      4 | at_home  | services | home       | mother     |            1 |           3 |          1 | no          | yes      | yes    | no           | yes       | yes      | yes        | yes        |        4 |          4 |       3 |      3 |      4 |        5 |         28 |
|  206 | GP       | F     |    16 | U         | GT3       | A         |      3 |      1 | services | other    | course     | mother     |            1 |           2 |          3 | no          | yes      | yes    | no           | yes       | yes      | yes        | no         |        2 |          3 |       3 |      2 |      2 |        4 |          5 |


Target Schema:
| school   |   ID |   sex |   age |   address |   famsize |   Pstatus |   Medu |   Fedu |   Mjob |   Fjob |   reason |   guardian |   traveltime |   studytime |   failures |   schoolsup |   famsup |   paid |   activities |   nursery |   higher |   internet |   romantic |   famrel |   freetime |   goout |   Dalc |   Walc |   health |   absences |   G1 |   G2 |   G3 |
|:---------|-----:|------:|------:|----------:|----------:|----------:|-------:|-------:|-------:|-------:|---------:|-----------:|-------------:|------------:|-----------:|------------:|---------:|-------:|-------------:|----------:|---------:|-----------:|-----------:|---------:|-----------:|--------:|-------:|-------:|---------:|-----------:|-----:|-----:|-----:|
| GP       |  197 |   197 |   197 |       197 |       197 |       197 |    197 |    197 |    197 |    197 |      197 |        197 |          197 |         197 |        197 |         197 |      197 |    197 |          197 |       197 |      197 |        197 |        197 |      197 |        197 |     197 |    197 |    197 |      197 |        197 |  197 |  197 |  197 |

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