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:
|   movie id | movie title                                          |
|-----------:|:-----------------------------------------------------|
|          1 | Toy Story (1995)                                     |
|          2 | GoldenEye (1995)                                     |
|          3 | Four Rooms (1995)                                    |
|          4 | Get Shorty (1995)                                    |
|          5 | Copycat (1995)                                       |
|          6 | Shanghai Triad (Yao a yao yao dao waipo qiao) (1995) |
|          7 | Twelve Monkeys (1995)                                |
|          8 | Babe (1995)                                          |
|          9 | Dead Man Walking (1995)                              |
|         10 | Richard III (1995)                                   |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   user_id |   movie_id |   rating |
|----------:|-----------:|---------:|
|       391 |        479 |        4 |
|       916 |        831 |        1 |
|       505 |         71 |        4 |
|       693 |        229 |        2 |
|       790 |        122 |        2 |
|       650 |        137 |        3 |
|       931 |        459 |        4 |
|       887 |        228 |        4 |
|       653 |         89 |        5 |
|       497 |        210 |        4 |


Target Schema:
| movie title                                 |   movie id |   user_id |   movie_id |   rating |
|:--------------------------------------------|-----------:|----------:|-----------:|---------:|
| 'Til There Was You (1997)                   |          6 |         6 |          6 |        6 |
| 1-900 (1994)                                |          2 |         2 |          2 |        2 |
| 101 Dalmatians (1996)                       |         52 |        52 |         52 |       52 |
| 12 Angry Men (1957)                         |         61 |        61 |         61 |       61 |
| 187 (1997)                                  |         18 |        18 |         18 |       18 |
| 2 Days in the Valley (1996)                 |         39 |        39 |         39 |       39 |
| 20,000 Leagues Under the Sea (1954)         |         31 |        31 |         31 |       31 |
| 2001: A Space Odyssey (1968)                |        128 |       128 |        128 |      128 |
| 3 Ninjas: High Noon At Mega Mountain (1998) |          4 |         4 |          4 |        4 |
| 39 Steps, The (1935)                        |         31 |        31 |         31 |       31 |

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