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 | name                | gender   | grade   | school             |   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 | 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 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| school                |   Average Math Score |   Average Reading Score |   Number Passing Math |   Number Passing Reading |
|:----------------------|---------------------:|------------------------:|----------------------:|-------------------------:|
| Bailey High School    |                77.04 |                   81.03 |                  3318 |                     4077 |
| Cabrera High School   |                83.06 |                   83.97 |                  1749 |                     1803 |
| Figueroa High School  |                76.71 |                   81.15 |                  1946 |                     2381 |
| Ford High School      |                77.1  |                   80.74 |                  1871 |                     2172 |
| Griffin High School   |                83.35 |                   83.81 |                  1371 |                     1426 |
| Hernandez High School |                77.28 |                   80.93 |                  3094 |                     3748 |
| Holden High School    |                83.8  |                   83.81 |                   395 |                      411 |
| Huang High School     |                76.62 |                   81.18 |                  1916 |                     2372 |
| Johnson High School   |                77.07 |                   80.96 |                  3145 |                     3867 |
| Pena High School      |                83.83 |                   84.04 |                   910 |                      923 |


Target Schema:
|   School ID | name                  | type     |   size |   budget |   Average Math Score |   Average Reading Score |   Number Passing Math |   Number Passing Reading |
|------------:|:----------------------|:---------|-------:|---------:|---------------------:|------------------------:|----------------------:|-------------------------:|
|           0 | Huang High School     | District |   2917 |  1910635 |                76.62 |                   81.18 |                  1916 |                     2372 |
|           1 | Figueroa High School  | District |   2949 |  1884411 |                76.71 |                   81.15 |                  1946 |                     2381 |
|           2 | Shelton High School   | Charter  |   1761 |  1056600 |                83.35 |                   83.72 |                  1653 |                     1688 |
|           3 | Hernandez High School | District |   4635 |  3022020 |                77.28 |                   80.93 |                  3094 |                     3748 |
|           4 | Griffin High School   | Charter  |   1468 |   917500 |                83.35 |                   83.81 |                  1371 |                     1426 |
|           5 | Wilson High School    | Charter  |   2283 |  1319574 |                83.27 |                   83.98 |                  2143 |                     2204 |
|           6 | Cabrera High School   | Charter  |   1858 |  1081356 |                83.06 |                   83.97 |                  1749 |                     1803 |
|           7 | Bailey High School    | District |   4976 |  3124928 |                77.1  |                   80.85 |                  3318 |                     4077 |

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