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:
| States               |   Unemployment Rate |
|:---------------------|--------------------:|
| UNITED STATES        |                 4.6 |
| ALABAMA              |                 4   |
| ALASKA               |                 6.6 |
| ARIZONA              |                 4.2 |
| ARKANSAS             |                 5.2 |
| CALIFORNIA           |                 4.9 |
| COLORADO             |                 4.3 |
| CONNECTICUT          |                 4.3 |
| DELAWARE             |                 3.6 |
| DISTRICT OF COLUMBIA |                 5.8 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| States               |   2007 |
|:---------------------|-------:|
| UNITED STATES        |  50233 |
| ALABAMA              |  42212 |
| ALASKA               |  62993 |
| ARIZONA              |  47215 |
| ARKANSAS             |  40795 |
| CALIFORNIA           |  55734 |
| COLORADO             |  61141 |
| CONNECTICUT          |  64141 |
| DELAWARE             |  54589 |
| DISTRICT OF COLUMBIA |  50783 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| States               |   2005 |
|:---------------------|-------:|
| UNITED STATES        |  46326 |
| ALABAMA              |  37150 |
| ALASKA               |  55891 |
| ARIZONA              |  45245 |
| ARKANSAS             |  36658 |
| CALIFORNIA           |  51755 |
| COLORADO             |  50449 |
| CONNECTICUT          |  56835 |
| DELAWARE             |  51235 |
| DISTRICT OF COLUMBIA |  44993 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
| States         |   2005 |
|:---------------|-------:|
| MISSOURI       |  42986 |
| MONTANA        |  37313 |
| NEBRASKA       |  47923 |
| NEVADA         |  48209 |
| NEW HAMPSHIRE  |  56984 |
| NEW JERSEY     |  63368 |
| NEW MEXICO     |  38947 |
| NEW YORK       |  47176 |
| NORTH CAROLINA |  42056 |
| NORTH DAKOTA   |  42192 |


Table #5
Filename: source_4.csv
Sample Rows in Markdown:
| States               |   Unemployment Rate |
|:---------------------|--------------------:|
| UNITED STATES        |                 5.1 |
| ALABAMA              |                 4.5 |
| ALASKA               |                 6.9 |
| ARIZONA              |                 4.7 |
| ARKANSAS             |                 5.2 |
| CALIFORNIA           |                 5.4 |
| COLORADO             |                 5   |
| CONNECTICUT          |                 4.9 |
| DELAWARE             |                 4.1 |
| DISTRICT OF COLUMBIA |                 6.4 |


Table #6
Filename: source_5.csv
Sample Rows in Markdown:
| States               |   Unemployment Rate |
|:---------------------|--------------------:|
| UNITED STATES        |                 4.6 |
| ALABAMA              |                 4   |
| ALASKA               |                 6.3 |
| ARIZONA              |                 3.9 |
| ARKANSAS             |                 5.3 |
| CALIFORNIA           |                 5.4 |
| COLORADO             |                 3.7 |
| CONNECTICUT          |                 4.5 |
| DELAWARE             |                 3.4 |
| DISTRICT OF COLUMBIA |                 5.5 |


Table #7
Filename: source_6.csv
Sample Rows in Markdown:
| States               |   2006 |
|:---------------------|-------:|
| UNITED STATES        |  48201 |
| ALABAMA              |  37952 |
| ALASKA               |  56418 |
| ARIZONA              |  46657 |
| ARKANSAS             |  37057 |
| CALIFORNIA           |  55319 |
| COLORADO             |  55697 |
| CONNECTICUT          |  62404 |
| DELAWARE             |  52438 |
| DISTRICT OF COLUMBIA |  48477 |


Table #8
Filename: source_7.csv
Sample Rows in Markdown:
| States               |   2006 |
|:---------------------|-------:|
| UNITED STATES        |  48201 |
| ALABAMA              |  37952 |
| ALASKA               |  56418 |
| ARIZONA              |  46657 |
| ARKANSAS             |  37057 |
| CALIFORNIA           |  55319 |
| COLORADO             |  55697 |
| CONNECTICUT          |  62404 |
| DELAWARE             |  52438 |
| DISTRICT OF COLUMBIA |  48477 |


Table #9
Filename: source_8.csv
Sample Rows in Markdown:
| States               |   2007 |
|:---------------------|-------:|
| UNITED STATES        |  50233 |
| ALABAMA              |  42212 |
| ALASKA               |  62993 |
| ARIZONA              |  47215 |
| ARKANSAS             |  40795 |
| CALIFORNIA           |  55734 |
| COLORADO             |  61141 |
| CONNECTICUT          |  64141 |
| DELAWARE             |  54589 |
| DISTRICT OF COLUMBIA |  50783 |


Target Schema:
| States               |   2005 |   Unemployment Rate |   2005_3 | 2006_x   | 2006_y   | 2007_x   | 2007_y   |
|:---------------------|-------:|--------------------:|---------:|:---------|:---------|:---------|:---------|
| UNITED STATES        |  46326 |                 5.1 |    46326 |          |          |          |          |
| ALABAMA              |  37150 |                 4.5 |    37150 |          |          |          |          |
| ALASKA               |  55891 |                 6.9 |    55891 |          |          |          |          |
| ARIZONA              |  45245 |                 4.7 |    45245 |          |          |          |          |
| ARKANSAS             |  36658 |                 5.2 |    36658 |          |          |          |          |
| CALIFORNIA           |  51755 |                 5.4 |    51755 |          |          |          |          |
| COLORADO             |  50449 |                 5   |    50449 |          |          |          |          |
| CONNECTICUT          |  56835 |                 4.9 |    56835 |          |          |          |          |
| DELAWARE             |  51235 |                 4.1 |    51235 |          |          |          |          |
| DISTRICT OF COLUMBIA |  44993 |                 6.4 |    44993 |          |          |          |          |

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
source_4.csv
source_5.csv
source_6.csv
source_7.csv
source_8.csv
test: test_0.csv
test_1.csv
test_2.csv
test_3.csv
test_4.csv
test_5.csv
test_6.csv
test_7.csv
test_8.csv