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:
|   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 #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:
|   user_id |   movie_id |   rating |   timestamp |
|----------:|-----------:|---------:|------------:|
|      5448 |       2384 |        3 | 9.59965e+08 |
|      4318 |       1097 |        5 | 9.65379e+08 |
|      4064 |       1293 |        4 | 9.65478e+08 |
|      2344 |       2599 |        2 | 9.74413e+08 |
|      4658 |       2748 |        1 | 9.63968e+08 |
|      3900 |       1711 |        4 | 9.65876e+08 |
|      1246 |       3363 |        2 | 1.02968e+09 |
|      3272 |       3587 |        3 | 9.68201e+08 |
|        45 |        728 |        4 | 9.7799e+08  |
|      2996 |        325 |        1 | 9.7277e+08  |


Target Schema:
| title                             |   user_id |   movie_id |   rating |   timestamp |     age |   occupation |
|:----------------------------------|----------:|-----------:|---------:|------------:|--------:|-------------:|
| $1,000,000 Duck (1971)            |   2186.67 |       2031 |  3       | 9.72628e+08 | 35      |      2.33333 |
| 'Night Mother (1986)              |   2712    |       3112 |  3       | 9.69226e+08 | 38.75   |      5.5     |
| 'Til There Was You (1997)         |   3795.25 |        779 |  2.75    | 9.67454e+08 | 24      |      8.625   |
| 'burbs, The (1989)                |   2678.93 |       2072 |  2.85185 | 9.71332e+08 | 28.5185 |      4.44444 |
| ...And Justice for All (1979)     |   3602.79 |       3420 |  3.78947 | 9.67693e+08 | 33.2105 |      7.52632 |
| 1-900 (1994)                      |   3402.5  |        889 |  2.5     | 9.70641e+08 | 40.5    |     11.5     |
| 10 Things I Hate About You (1999) |   2812.49 |       2572 |  3.36364 | 9.74726e+08 | 26.5065 |      7.31169 |
| 101 Dalmatians (1961)             |   3202.44 |       2085 |  3.57627 | 9.69862e+08 | 26.2712 |      7.27119 |
| 101 Dalmatians (1996)             |   2971.83 |       1367 |  2.90476 | 9.70899e+08 | 30.2143 |      6.09524 |
| 12 Angry Men (1957)               |   3065.66 |       1203 |  4.27869 | 9.72191e+08 | 31.8033 |      8.45902 |

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