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:
|   user_id | year_school   | floor   |
|----------:|:--------------|:--------|
|        43 | Freshman      | f282.2  |
|        44 | Sophomore     | f282.2  |
|        45 | Freshman      | f290.4  |
|        46 | Sophomore     | f282.3  |
|        47 | Junior        | f282.3  |
|        48 | GRT / Other   | f290.2  |
|        49 | Senior        | f290.2  |
|        50 | GRT / Other   | f290.4  |
|        51 | GRT / Other   | f282.4  |
|        52 | Freshman      | f282.1  |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   user_id | party   | libcon   |
|----------:|:--------|:---------|
|        55 | TYPEc   | TYPEc    |
|        36 | TYPEb   | TYPEb    |
|        39 | TYPEa   | TYPEe    |
|        37 | TYPEa   | TYPEg    |
|        72 | TYPEa   | TYPEf    |
|        11 | TYPEa   | TYPEd    |
|        63 | TYPEb   | TYPEc    |
|        21 | TYPEb   | TYPEc    |
|        59 | TYPEc   | TYPEe    |
|        47 | TYPEc   | TYPEd    |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|   user_id | fav_music   |
|----------:|:------------|
|         0 | TYPEf       |
|         1 | TYPEd       |
|         2 | TYPEa       |
|         3 | TYPEg       |
|         4 | TYPEa       |
|         5 | TYPEk       |
|         6 | TYPEf       |
|         7 | TYPEa       |
|         8 | TYPEk       |
|         9 | TYPEb       |


Target Schema:
|   user_id | year_school   | floor   | party   | libcon   | fav_music   |
|----------:|:--------------|:--------|:--------|:---------|:------------|
|         1 | GRT / Other   | f282.2  | TYPEa   | TYPEf    | TYPEd       |
|         2 | Freshman      | f282.4  | TYPEd   | TYPEf    | TYPEa       |
|         3 | Sophomore     | f282.4  | TYPEa   | TYPEe    | TYPEg       |
|         4 | Sophomore     | f282.1  | TYPEa   | TYPEf    | TYPEa       |
|         5 | Freshman      | f282.3  | TYPEc   | TYPEe    | TYPEk       |
|         6 | Sophomore     | f282.3  | TYPEa   | TYPEg    | TYPEf       |
|         7 | Junior        | f282.1  | TYPEa   | TYPEf    | TYPEa       |
|         8 | Freshman      | f282.4  | TYPEa   | TYPEd    | TYPEk       |
|         9 | Sophomore     | f290.4  | TYPEd   | TYPEg    | TYPEb       |
|        10 | Sophomore     | f290.4  | TYPEa   | TYPEf    | TYPEi       |

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