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:
|       x |       y | label   |
|--------:|--------:|:--------|
| 3.01988 | 3.55624 | purple  |
| 3.02621 | 3.13646 | purple  |
| 3.02831 | 3.05992 | purple  |
| 3.24621 | 3.12134 | purple  |
| 3.86003 | 3.04455 | purple  |
| 3.53883 | 3.10749 | purple  |
| 3.55282 | 3.22571 | purple  |
| 3.84203 | 3.71299 | purple  |
| 3.12417 | 3.55972 | purple  |
| 3.27918 | 3.01256 | purple  |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|       x |       y | label   |
|--------:|--------:|:--------|
| 3.88331 | 1.32664 | b       |
| 3.62367 | 1.52706 | b       |
| 3.75094 | 1.88594 | b       |
| 3.3489  | 1.35727 | b       |
| 3.26993 | 1.90854 | b       |
| 3.89589 | 1.62336 | b       |
| 3.42809 | 1.01582 | b       |
| 3.96484 | 1.92944 | b       |
| 3.66344 | 1.6909  | b       |
| 3.6217  | 1.99732 | b       |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|       x |       y | label   |
|--------:|--------:|:--------|
| 1.98886 | 3.10233 | g       |
| 1.74817 | 3.41406 | g       |
| 1.28044 | 3.6944  | g       |
| 1.78928 | 3.41418 | g       |
| 1.10323 | 3.04995 | g       |
| 1.44789 | 3.5359  | g       |
| 1.9086  | 3.66379 | g       |
| 1.29361 | 3.51489 | g       |
| 1.28778 | 3.94459 | g       |
| 1.13003 | 3.58656 | g       |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
|       x |       y | label   |
|--------:|--------:|:--------|
| 1.41919 | 1.09835 | r       |
| 1.68522 | 1.42111 | r       |
| 1.20445 | 1.95789 | r       |
| 1.87812 | 1.53317 | r       |
| 1.02739 | 1.69188 | r       |
| 1.67047 | 1.31552 | r       |
| 1.4173  | 1.6865  | r       |
| 1.55869 | 1.83463 | r       |
| 1.14039 | 1.01829 | r       |
| 1.1981  | 1.75014 | r       |


Target Schema:
|       x |   y |   label |
|--------:|----:|--------:|
| 1.00011 |   1 |       1 |
| 1.01937 |   1 |       1 |
| 1.05336 |   1 |       1 |
| 1.09234 |   1 |       1 |
| 1.10323 |   1 |       1 |
| 1.13003 |   1 |       1 |
| 1.14673 |   1 |       1 |
| 1.14676 |   1 |       1 |
| 1.18626 |   1 |       1 |
| 1.21163 |   1 |       1 |

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