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:
|   Student ID | student_name        | gender   | grade   | school_name        |   reading_score |   math_score |
|-------------:|:--------------------|:---------|:--------|:-------------------|----------------:|-------------:|
|        19585 | Alicia Butler       | F        | 9th     | Bailey High School |              69 |           71 |
|        19586 | Amanda Adams        | F        | 11th    | Bailey High School |              91 |           83 |
|        19587 | James Brown         | M        | 9th     | Bailey High School |              76 |           92 |
|        19588 | Anthony Holmes      | M        | 11th    | Bailey High School |              86 |           76 |
|        19589 | Jacqueline Williams | F        | 10th    | Bailey High School |              79 |           75 |
|        19590 | Julie Brown         | F        | 11th    | Bailey High School |              94 |           99 |
|        19591 | Scott Gibson        | M        | 11th    | Bailey High School |              91 |           71 |
|        19592 | Anthony Reeves      | M        | 12th    | Bailey High School |              99 |           60 |
|        19593 | Diane Vargas        | F        | 9th     | Bailey High School |              99 |           80 |
|        19594 | Kathryn Jones       | F        | 10th    | Bailey High School |              73 |           97 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   School ID | school_name           | type     |   size |   budget |
|------------:|:----------------------|:---------|-------:|---------:|
|           0 | Huang High School     | District |   2917 |  1910635 |
|           1 | Figueroa High School  | District |   2949 |  1884411 |
|           2 | Shelton High School   | Charter  |   1761 |  1056600 |
|           3 | Hernandez High School | District |   4635 |  3022020 |
|           4 | Griffin High School   | Charter  |   1468 |   917500 |
|           5 | Wilson High School    | Charter  |   2283 |  1319574 |
|           6 | Cabrera High School   | Charter  |   1858 |  1081356 |
|           7 | Bailey High School    | District |   4976 |  3124928 |
|           8 | Holden High School    | Charter  |    427 |   248087 |
|           9 | Pena High School      | Charter  |    962 |   585858 |


Target Schema:
| school_name           |   Student ID |   student_name |   gender |   grade |   reading_score |   math_score |   School ID |   type |   size |   budget |
|:----------------------|-------------:|---------------:|---------:|--------:|----------------:|-------------:|------------:|-------:|-------:|---------:|
| Bailey High School    |         1714 |           1714 |     1714 |    1714 |            1714 |         1714 |        1714 |   1714 |   1714 |     1714 |
| Cabrera High School   |         1858 |           1858 |     1858 |    1858 |            1858 |         1858 |        1858 |   1858 |   1858 |     1858 |
| Figueroa High School  |         2949 |           2949 |     2949 |    2949 |            2949 |         2949 |        2949 |   2949 |   2949 |     2949 |
| Griffin High School   |         1468 |           1468 |     1468 |    1468 |            1468 |         1468 |        1468 |   1468 |   1468 |     1468 |
| Hernandez High School |         4635 |           4635 |     4635 |    4635 |            4635 |         4635 |        4635 |   4635 |   4635 |     4635 |
| Huang High School     |         2917 |           2917 |     2917 |    2917 |            2917 |         2917 |        2917 |   2917 |   2917 |     2917 |
| Shelton High School   |         1761 |           1761 |     1761 |    1761 |            1761 |         1761 |        1761 |   1761 |   1761 |     1761 |
| Wilson High School    |         2283 |           2283 |     2283 |    2283 |            2283 |         2283 |        2283 |   2283 |   2283 |     2283 |

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