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 |   movie_id |   rating |
|----------:|-----------:|---------:|
|       848 |        443 |        5 |
|       464 |       1025 |        2 |
|       514 |        190 |        5 |
|       727 |        188 |        3 |
|       737 |        156 |        5 |
|       557 |        875 |        4 |
|        85 |        478 |        4 |
|       896 |        651 |        4 |
|       637 |       1244 |        1 |
|       703 |        275 |        4 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   movie_id | 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)                                   |


Target Schema:
| title                                       |   size |    mean |
|:--------------------------------------------|-------:|--------:|
| 'Til There Was You (1997)                   |      6 | 2.33333 |
| 1-900 (1994)                                |      2 | 2.5     |
| 101 Dalmatians (1996)                       |     52 | 2.94231 |
| 12 Angry Men (1957)                         |     61 | 4.31148 |
| 187 (1997)                                  |     18 | 2.88889 |
| 2 Days in the Valley (1996)                 |     39 | 3.25641 |
| 20,000 Leagues Under the Sea (1954)         |     31 | 3.48387 |
| 2001: A Space Odyssey (1968)                |    128 | 4.08594 |
| 3 Ninjas: High Noon At Mega Mountain (1998) |      4 | 1       |
| 39 Steps, The (1935)                        |     31 | 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
test: test_0.csv
test_1.csv