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 |
|----------:|-----------:|---------:|------------:|
|      3503 |       3397 |        4 | 9.6775e+08  |
|      5571 |       1228 |        4 | 9.59305e+08 |
|      1274 |       1295 |        5 | 9.74811e+08 |
|      3618 |       3219 |        4 | 9.66597e+08 |
|      2463 |       1291 |        4 | 9.74224e+08 |
|      4596 |       1983 |        2 | 9.64223e+08 |
|       223 |        780 |        5 | 9.76903e+08 |
|      4342 |       3707 |        5 | 9.65233e+08 |
|      3685 |       1095 |        5 | 9.66864e+08 |
|      2624 |       1198 |        5 | 9.7364e+08  |


Target Schema:
|   user_id |   movie_id |   rating |   timestamp | gender   |   age |   occupation |   zip | title                       | genres                  |
|----------:|-----------:|---------:|------------:|:---------|------:|-------------:|------:|:----------------------------|:------------------------|
|      5140 |       1269 |        4 |   962058225 | M        |    25 |            6 | 35205 | Arsenic and Old Lace (1944) | Comedy|Mystery|Thriller |
|       195 |       1269 |        4 |   977749101 | M        |    25 |           12 | 10458 | Arsenic and Old Lace (1944) | Comedy|Mystery|Thriller |
|      4144 |       1269 |        4 |   965346761 | M        |    18 |            4 | 02451 | Arsenic and Old Lace (1944) | Comedy|Mystery|Thriller |
|      1599 |       1269 |        4 |   974757903 | M        |    25 |            0 | 92646 | Arsenic and Old Lace (1944) | Comedy|Mystery|Thriller |
|      3248 |       1269 |        4 |   968303681 | F        |    25 |            7 | 94115 | Arsenic and Old Lace (1944) | Comedy|Mystery|Thriller |
|      4506 |       1269 |        4 |   964985451 | M        |    50 |           16 | 29464 | Arsenic and Old Lace (1944) | Comedy|Mystery|Thriller |
|       549 |       1269 |        4 |   976122048 | M        |    25 |            6 | 53217 | Arsenic and Old Lace (1944) | Comedy|Mystery|Thriller |
|      3201 |       1269 |        5 |   968623440 | M        |    45 |            7 | 35216 | Arsenic and Old Lace (1944) | Comedy|Mystery|Thriller |
|       396 |       1269 |        4 |   976296952 | M        |    25 |            1 | 56187 | Arsenic and Old Lace (1944) | Comedy|Mystery|Thriller |
|      2073 |       1269 |        5 |   974661629 | F        |    18 |            4 | 13148 | Arsenic and Old Lace (1944) | Comedy|Mystery|Thriller |

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