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 |
|----------:|-----------:|---------:|------------:|
|      2389 |       2427 |        2 | 9.74328e+08 |
|      1369 |       1620 |        5 | 9.74773e+08 |
|      2203 |        327 |        1 | 9.74604e+08 |
|      5341 |        260 |        5 | 9.60693e+08 |
|      1100 |       3397 |        3 | 9.74924e+08 |
|      2216 |       2750 |        5 | 9.74601e+08 |
|      5472 |       1688 |        3 | 9.599e+08   |
|      3826 |       3783 |        4 | 9.65935e+08 |
|      1733 |       2519 |        4 | 9.77808e+08 |
|      5046 |       1199 |        2 | 9.62499e+08 |


Target Schema:
| title                             |       F | M                  |
|:----------------------------------|--------:|:-------------------|
| $1,000,000 Duck (1971)            | 3.66667 | 2.5                |
| 'Night Mother (1986)              | 3.6     | 3.8                |
| 'Til There Was You (1997)         | 2.75    |                    |
| 'burbs, The (1989)                | 2.71429 | 3.6                |
| ...And Justice for All (1979)     | 3.75    | 3.4444444444444446 |
| 10 Things I Hate About You (1999) | 3.45833 | 3.0576923076923075 |
| 101 Dalmatians (1961)             | 3.70588 | 3.6                |
| 101 Dalmatians (1996)             | 2.86667 | 2.896551724137931  |
| 12 Angry Men (1957)               | 4.22222 | 4.48936170212766   |
| 13th Warrior, The (1999)          | 3.22222 | 3.029850746268657  |

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