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:
|   userId |   movieId |   rating |   timestamp |
|---------:|----------:|---------:|------------:|
|      561 |     99114 |      3   | 1.49109e+09 |
|      474 |      8128 |      3.5 | 1.18999e+09 |
|      477 |      2424 |      4   | 1.20094e+09 |
|      409 |      2361 |      3   | 9.6792e+08  |
|      429 |       339 |      5   | 8.28125e+08 |
|      414 |      3504 |      4   | 9.61595e+08 |
|      414 |      4380 |      5   | 1.01646e+09 |
|      398 |      1136 |      5   | 1.31121e+09 |
|      386 |       173 |      2   | 8.42614e+08 |
|      448 |    132618 |      1.5 | 1.47567e+09 |


Table #2
Filename: source_1.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                   |


Target Schema:
|   movieId | title                              | genres                                      |   userId |   rating |
|----------:|:-----------------------------------|:--------------------------------------------|---------:|---------:|
|         1 | Toy Story (1995)                   | Adventure|Animation|Children|Comedy|Fantasy |  163.855 |  3.87179 |
|         2 | Jumanji (1995)                     | Adventure|Children|Fantasy                  |  176.804 |  3.33036 |
|         3 | Grumpier Old Men (1995)            | Comedy|Romance                              |  154.188 |  3.29688 |
|         4 | Waiting to Exhale (1995)           | Comedy|Drama|Romance                        |  105.6   |  2.6     |
|         5 | Father of the Bride Part II (1995) | Comedy                                      |  144.231 |  3.46154 |
|         6 | Heat (1995)                        | Action|Crime|Thriller                       |  166.182 |  3.85455 |
|         7 | Sabrina (1995)                     | Comedy|Romance                              |  139.303 |  3.31818 |
|         8 | Tom and Huck (1995)                | Adventure|Children                          |   85.75  |  3       |
|         9 | Sudden Death (1995)                | Action                                      |  217.2   |  3       |
|        10 | GoldenEye (1995)                   | Action|Adventure|Thriller                   |  163.687 |  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