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:
| State Name     |   AQI |   Year |   Month |
|:---------------|------:|-------:|--------:|
| Rhode Island   |    50 |   2018 |       4 |
| Oklahoma       |    37 |   2018 |      10 |
| Pennsylvania   |    29 |   2018 |       1 |
| Oklahoma       |    41 |   2018 |       8 |
| Montana        |    26 |   2018 |       3 |
| Oklahoma       |    29 |   2018 |       4 |
| Oklahoma       |    34 |   2018 |      10 |
| Ohio           |    51 |   2018 |      12 |
| South Carolina |    34 |   2018 |      12 |
| Nebraska       |    29 |   2018 |       9 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| State Name     |   AQI |   Year |   Month |
|:---------------|------:|-------:|--------:|
| Indiana        |    38 |   2015 |       6 |
| Kentucky       |    18 |   2015 |       1 |
| Hawaii         |    28 |   2015 |       3 |
| Alabama        |    53 |   2015 |       3 |
| Kansas         |    46 |   2015 |       4 |
| Washington     |    25 |   2015 |       4 |
| Oregon         |    17 |   2015 |       4 |
| Texas          |    35 |   2015 |       9 |
| Washington     |    44 |   2015 |       9 |
| North Carolina |    32 |   2015 |       8 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| State Name    |   AQI |   Year |   Month |
|:--------------|------:|-------:|--------:|
| Pennsylvania  |    23 |   2016 |       9 |
| Utah          |    44 |   2016 |      10 |
| Wisconsin     |    60 |   2016 |      10 |
| Florida       |    33 |   2016 |       7 |
| Oklahoma      |    37 |   2016 |       9 |
| Georgia       |    25 |   2016 |       7 |
| Montana       |    15 |   2016 |       5 |
| New Jersey    |    29 |   2016 |      10 |
| Indiana       |    41 |   2016 |       4 |
| New Hampshire |    37 |   2016 |       4 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
| State Name     |   AQI |   Year |   Month |
|:---------------|------:|-------:|--------:|
| Montana        |    43 |   2017 |       8 |
| Wyoming        |    61 |   2017 |      10 |
| Texas          |    45 |   2017 |      11 |
| Alabama        |    14 |   2017 |       9 |
| Missouri       |    31 |   2017 |      10 |
| North Carolina |    19 |   2017 |      10 |
| Alabama        |    58 |   2017 |       2 |
| Louisiana      |    39 |   2017 |       2 |
| North Carolina |    58 |   2017 |       5 |
| Arizona        |    62 |   2017 |      11 |


Target Schema:
| State Name   |   Year |   Month |   AQI |
|:-------------|-------:|--------:|------:|
| Alabama      |   2015 |       1 |   141 |
| Alabama      |   2015 |       2 |   170 |
| Alabama      |   2015 |       3 |   101 |
| Alabama      |   2015 |       4 |    80 |
| Alabama      |   2015 |       5 |   122 |
| Alabama      |   2015 |       6 |   112 |
| Alabama      |   2015 |       7 |    90 |
| Alabama      |   2015 |       8 |   147 |
| Alabama      |   2015 |       9 |    97 |
| Alabama      |   2015 |      10 |   129 |

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