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:
|   missing_count | state          |   latitude |   longitude |
|----------------:|:---------------|-----------:|------------:|
|               0 | Montana        |    46.9048 |   -110.326  |
|               0 | Nebraska       |    41.1289 |    -98.2883 |
|               0 | Nevada         |    38.4199 |   -117.122  |
|               0 | New Hampshire  |    43.4108 |    -71.5653 |
|               0 | New Jersey     |    40.314  |    -74.5089 |
|               0 | New Mexico     |    34.8375 |   -106.237  |
|               0 | New York       |    42.1497 |    -74.9384 |
|               0 | North Carolina |    35.6411 |    -79.8431 |
|               0 | North Dakota   |    47.5362 |    -99.793  |
|               0 | Ohio           |    40.3736 |    -82.7755 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   missing_count | state       |   latitude |   longitude |
|----------------:|:------------|-----------:|------------:|
|               0 | Alabama     |    32.799  |    -86.8073 |
|               0 | Alaska      |    61.385  |   -152.268  |
|               0 | Arizona     |    33.7712 |   -111.388  |
|               0 | Arkansas    |    34.9513 |    -92.3809 |
|               0 | California  |    36.17   |   -119.746  |
|               0 | Colorado    |    39.0646 |   -105.327  |
|               0 | Connecticut |    41.5834 |    -72.7622 |
|               0 | Delaware    |    39.3498 |    -75.5148 |
|               0 | Florida     |    27.8333 |    -81.717  |
|               0 | Georgia     |    32.9866 |    -83.6487 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|   missing_count | state       |   latitude |   longitude |
|----------------:|:------------|-----------:|------------:|
|               0 | Alabama     |    32.799  |    -86.8073 |
|               0 | Alaska      |    61.385  |   -152.268  |
|               0 | Arizona     |    33.7712 |   -111.388  |
|               0 | Arkansas    |    34.9513 |    -92.3809 |
|               0 | California  |    36.17   |   -119.746  |
|               0 | Colorado    |    39.0646 |   -105.327  |
|               0 | Connecticut |    41.5834 |    -72.7622 |
|               0 | Delaware    |    39.3498 |    -75.5148 |
|               0 | Florida     |    27.8333 |    -81.717  |
|               0 | Georgia     |    32.9866 |    -83.6487 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
|   missing_count | state       |   latitude |   longitude |
|----------------:|:------------|-----------:|------------:|
|               0 | Alabama     |    32.799  |    -86.8073 |
|               0 | Alaska      |    61.385  |   -152.268  |
|               0 | Arizona     |    33.7712 |   -111.388  |
|               0 | Arkansas    |    34.9513 |    -92.3809 |
|               0 | California  |    36.17   |   -119.746  |
|               0 | Colorado    |    39.0646 |   -105.327  |
|               0 | Connecticut |    41.5834 |    -72.7622 |
|               0 | Delaware    |    39.3498 |    -75.5148 |
|               0 | Florida     |    27.8333 |    -81.717  |
|               0 | Georgia     |    32.9866 |    -83.6487 |


Table #5
Filename: source_4.csv
Sample Rows in Markdown:
|   missing_count | state       |   latitude |   longitude |
|----------------:|:------------|-----------:|------------:|
|               0 | Alabama     |    32.799  |    -86.8073 |
|               0 | Alaska      |    61.385  |   -152.268  |
|               0 | Arizona     |    33.7712 |   -111.388  |
|               0 | Arkansas    |    34.9513 |    -92.3809 |
|               0 | California  |    36.17   |   -119.746  |
|               0 | Colorado    |    39.0646 |   -105.327  |
|               0 | Connecticut |    41.5834 |    -72.7622 |
|               0 | Delaware    |    39.3498 |    -75.5148 |
|               0 | Florida     |    27.8333 |    -81.717  |
|               0 | Georgia     |    32.9866 |    -83.6487 |


Target Schema:
|   longitude |   missing_count |   state |   latitude |
|------------:|----------------:|--------:|-----------:|
|    -157.531 |               5 |       5 |          5 |
|    -152.268 |               5 |       5 |          5 |
|    -122.127 |               4 |       4 |          4 |
|    -121.571 |               4 |       4 |          4 |
|    -119.746 |               5 |       5 |          5 |
|    -117.122 |               4 |       4 |          4 |
|    -114.51  |               5 |       5 |          5 |
|    -111.853 |               4 |       4 |          4 |
|    -111.388 |               5 |       5 |          5 |
|    -110.326 |               4 |       4 |          4 |

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