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 |   timestamp |
|----------:|-----------:|---------:|------------:|
|      3118 |       2640 |        3 | 9.69402e+08 |
|      1015 |       2153 |        2 | 9.75106e+08 |
|      1680 |       1717 |        4 | 9.74716e+08 |
|      5658 |        480 |        5 | 9.58808e+08 |
|      4510 |       1995 |        1 | 9.6499e+08  |
|      3314 |       1206 |        5 | 9.67944e+08 |
|      2537 |       2375 |        2 | 9.74053e+08 |
|      6040 |        306 |        4 | 9.57717e+08 |
|       352 |       2664 |        4 | 9.76325e+08 |
|      3311 |       1391 |        2 | 9.67955e+08 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   movie_id | title                              | genres                       |
|-----------:|:-----------------------------------|:-----------------------------|
|          1 | Toy Story (1995)                   | Animation|Children's|Comedy  |
|          2 | Jumanji (1995)                     | Adventure|Children's|Fantasy |
|          3 | Grumpier Old Men (1995)            | Comedy|Romance               |
|          4 | Waiting to Exhale (1995)           | Comedy|Drama                 |
|          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's         |
|          9 | Sudden Death (1995)                | Action                       |
|         10 | GoldenEye (1995)                   | Action|Adventure|Thriller    |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|   user_id | gender   |   age |   occupation |   zip |
|----------:|:---------|------:|-------------:|------:|
|         1 | F        |     1 |           10 | 48067 |
|         2 | M        |    56 |           16 | 70072 |
|         3 | M        |    25 |           15 | 55117 |
|         4 | M        |    45 |            7 | 02460 |
|         5 | M        |    25 |           20 | 55455 |
|         6 | F        |    50 |            9 | 55117 |
|         7 | M        |    35 |            1 | 06810 |
|         8 | M        |    25 |           12 | 11413 |
|         9 | M        |    25 |           17 | 61614 |
|        10 | F        |    35 |            1 | 95370 |


Target Schema:
| title                             |   user_id |     age |   occupation |   movie_id |   rating |   timestamp |
|:----------------------------------|----------:|--------:|-------------:|-----------:|---------:|------------:|
| $1,000,000 Duck (1971)            |   1498    | 41.6667 |      5.66667 |       2031 |  2.66667 | 9.88297e+08 |
| 'Night Mother (1986)              |   2380    | 36      |     10.5     |       3112 |  4       | 9.72448e+08 |
| 'Til There Was You (1997)         |   2838    | 25.375  |      8.125   |        779 |  3.125   | 9.77497e+08 |
| 'burbs, The (1989)                |   2639.97 | 29.8    |     10.8857  |       2072 |  2.88571 | 9.71688e+08 |
| ...And Justice for All (1979)     |   3457.05 | 37.15   |     10.65    |       3420 |  3.85    | 9.69283e+08 |
| 1-900 (1994)                      |   3015    | 56      |      6       |        889 |  3       | 9.75264e+08 |
| 10 Things I Hate About You (1999) |   3202.95 | 22.197  |      8       |       2572 |  3.42424 | 9.73817e+08 |
| 101 Dalmatians (1961)             |   3189.48 | 27.1346 |      6.88462 |       2085 |  3.65385 | 9.71273e+08 |
| 101 Dalmatians (1996)             |   3057.16 | 28.75   |      5.45455 |       1367 |  3.11364 | 9.72656e+08 |
| 12 Angry Men (1957)               |   3319.05 | 34.9848 |      8.19697 |       1203 |  4.36364 | 9.70126e+08 |

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