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 |
|----------:|-----------:|---------:|------------:|
|      2526 |       3789 |        3 | 9.74064e+08 |
|      3916 |       2231 |        4 | 9.65759e+08 |
|       770 |       2080 |        4 | 9.76182e+08 |
|      2955 |       1193 |        3 | 9.71206e+08 |
|      4089 |       2025 |        3 | 9.6543e+08  |
|      1605 |       2558 |        4 | 9.75382e+08 |
|      2852 |       1985 |        3 | 9.72508e+08 |
|      3518 |       1032 |        4 | 9.68171e+08 |
|      5056 |       1569 |        3 | 9.62489e+08 |
|      5612 |       2718 |        2 | 9.59174e+08 |


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


Target Schema:
| title                             |   user_id |   movie_id |   rating |   timestamp |     age |   occupation |
|:----------------------------------|----------:|-----------:|---------:|------------:|--------:|-------------:|
| $1,000,000 Duck (1971)            |   3331.25 |       2031 |  2.5     | 1.00385e+09 | 32.5    |      2.5     |
| 'Night Mother (1986)              |   2597.57 |       3112 |  3.14286 | 9.71152e+08 | 27.8571 |      4.14286 |
| 'Til There Was You (1997)         |   1865    |        779 |  2.42857 | 9.7629e+08  | 36.7143 |      7.42857 |
| 'burbs, The (1989)                |   2800.89 |       2072 |  3       | 9.70833e+08 | 27.4286 |      8.78571 |
| ...And Justice for All (1979)     |   2980.36 |       3420 |  3.48    | 9.74285e+08 | 36.4    |      8.64    |
| 10 Things I Hate About You (1999) |   2789.66 |       2572 |  3.5443  | 9.7492e+08  | 24.1519 |      7.70886 |
| 101 Dalmatians (1961)             |   3065.34 |       2085 |  3.56897 | 9.71927e+08 | 27.2069 |      7.10345 |
| 101 Dalmatians (1996)             |   2823.31 |       1367 |  2.69048 | 9.73569e+08 | 27.0714 |      6.52381 |
| 12 Angry Men (1957)               |   3171.11 |       1203 |  4.29231 | 9.75963e+08 | 29.7385 |      7.12308 |
| 13th Warrior, The (1999)          |   3081.94 |       2826 |  2.9375  | 9.70231e+08 | 26.2188 |      7.03125 |

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