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:
|   user_id |   movie_id |   rating |   timestamp |
|----------:|-----------:|---------:|------------:|
|       166 |        160 |        3 | 9.77297e+08 |
|      5294 |       1641 |        5 | 9.6104e+08  |
|      1649 |       1240 |        2 | 9.74712e+08 |
|      1613 |        104 |        4 | 9.74733e+08 |
|      1034 |        913 |        5 | 9.75197e+08 |
|      4611 |       1339 |        1 | 9.64156e+08 |
|      3868 |       2571 |        5 | 9.65848e+08 |
|      2887 |        195 |        3 | 9.72157e+08 |
|      2934 |        916 |        4 | 9.71487e+08 |
|       125 |       1912 |        4 | 9.77446e+08 |


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)            |   1964.83 |       2031 |  3.66667 | 9.7381e+08  | 30.1667 |      8.16667 |
| 'Night Mother (1986)              |   3879.5  |       3112 |  3       | 9.66716e+08 | 35      |      1.5     |
| 'Til There Was You (1997)         |    528    |        779 |  3       | 9.80041e+08 | 18      |     17       |
| 'burbs, The (1989)                |   2944.41 |       2072 |  3       | 9.72327e+08 | 29.1852 |      6.25926 |
| ...And Justice for All (1979)     |   3138.38 |       3420 |  3.70833 | 9.69093e+08 | 37.0417 |      7.54167 |
| 10 Things I Hate About You (1999) |   2919.95 |       2572 |  3.5122  | 9.72027e+08 | 22      |      6.37805 |
| 101 Dalmatians (1961)             |   3015.71 |       2085 |  3.67742 | 9.70619e+08 | 26.4839 |      6.54839 |
| 101 Dalmatians (1996)             |   3195.71 |       1367 |  2.82927 | 9.69967e+08 | 25.3902 |      7.26829 |
| 12 Angry Men (1957)               |   3247.61 |       1203 |  4.30357 | 9.71244e+08 | 34.0536 |      7.66071 |
| 13th Warrior, The (1999)          |   2961.15 |       2826 |  3.17949 | 9.72269e+08 | 27.2692 |      9.73077 |

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