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 | 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 |


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 |   movie_id |   rating |   timestamp |
|----------:|-----------:|---------:|------------:|
|      2288 |       2599 |        4 | 9.7452e+08  |
|      4030 |       3744 |        3 | 9.65597e+08 |
|       900 |       2732 |        4 | 9.75215e+08 |
|      2063 |       1034 |        3 | 9.75377e+08 |
|      2827 |       1196 |        4 | 9.72601e+08 |
|      1387 |        588 |        2 | 9.74766e+08 |
|      1733 |        220 |        3 | 9.77808e+08 |
|       275 |       1376 |        5 | 9.76593e+08 |
|      4802 |       2866 |        5 | 9.63198e+08 |
|      5002 |       2076 |        3 | 9.6259e+08  |


Target Schema:
| title                             |   user_id |     age |   occupation |   movie_id |   rating |   timestamp |
|:----------------------------------|----------:|--------:|-------------:|-----------:|---------:|------------:|
| $1,000,000 Duck (1971)            |   2030    | 25      |      4       |       2031 |  2       | 9.74746e+08 |
| 'Night Mother (1986)              |   3711.67 | 33.5    |      8.66667 |       3112 |  3       | 9.6968e+08  |
| 'Til There Was You (1997)         |   2474.5  | 31.6667 |      9.66667 |        779 |  3       | 9.70824e+08 |
| 'burbs, The (1989)                |   3405.21 | 31      |      9.45833 |       2072 |  2.79167 | 9.68953e+08 |
| ...And Justice for All (1979)     |   3180    | 31.4783 |      6.73913 |       3420 |  3.65217 | 9.69548e+08 |
| 10 Things I Hate About You (1999) |   3302.71 | 24.5584 |      7.44156 |       2572 |  3.48052 | 9.74227e+08 |
| 101 Dalmatians (1961)             |   2971.27 | 26.6327 |      7.2449  |       2085 |  3.59184 | 9.70378e+08 |
| 101 Dalmatians (1996)             |   3048.64 | 29.3409 |      7.04545 |       1367 |  3.25    | 9.70823e+08 |
| 12 Angry Men (1957)               |   3114.56 | 29.4737 |      6.52632 |       1203 |  4.24561 | 9.7262e+08  |
| 13th Warrior, The (1999)          |   2775.43 | 25.2911 |      8.70886 |       2826 |  3.18987 | 9.71616e+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