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:
|   movieId | title                              | genres                                      |
|----------:|:-----------------------------------|:--------------------------------------------|
|         1 | Toy Story (1995)                   | Adventure|Animation|Children|Comedy|Fantasy |
|         2 | Jumanji (1995)                     | Adventure|Children|Fantasy                  |
|         3 | Grumpier Old Men (1995)            | Comedy|Romance                              |
|         4 | Waiting to Exhale (1995)           | Comedy|Drama|Romance                        |
|         5 | Father of the Bride Part II (1995) | Comedy                                      |
|         6 | Heat (1995)                        | Action|Crime|Thriller                       |
|         7 | Sabrina (1995)                     | Comedy|Romance                              |
|         8 | Tom and Huck (1995)                | Adventure|Children                          |
|         9 | Sudden Death (1995)                | Action                                      |
|        10 | GoldenEye (1995)                   | Action|Adventure|Thriller                   |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   userId |   movieId |   rating |   timestamp |
|---------:|----------:|---------:|------------:|
|      380 |      1967 |      5   | 1.4948e+09  |
|      474 |       282 |      3   | 1.06011e+09 |
|      387 |      1610 |      3   | 1.09512e+09 |
|      489 |      1198 |      4   | 1.3331e+09  |
|      414 |       290 |      5   | 9.61517e+08 |
|      462 |     80862 |      4.5 | 1.47158e+09 |
|      599 |      3915 |      2   | 1.51924e+09 |
|      387 |      7698 |      4   | 1.09488e+09 |
|      438 |      6947 |      3   | 1.10566e+09 |
|      339 |      4993 |      3.5 | 1.46018e+09 |


Target Schema:
|   movieId |   rating |
|----------:|---------:|
|         1 |  3.87179 |
|         2 |  3.33036 |
|         3 |  3.29688 |
|         4 |  2.6     |
|         5 |  3.46154 |
|         6 |  3.85455 |
|         7 |  3.31818 |
|         8 |  3       |
|         9 |  3       |
|        10 |  3.51493 |

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