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                                                | release_date   | video_release_date   | imdb_url                                                       |
|-----------:|:-----------------------------------------------------|:---------------|:---------------------|:---------------------------------------------------------------|
|          1 | Toy Story (1995)                                     | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Toy%20Story%20(1995)          |
|          2 | GoldenEye (1995)                                     | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?GoldenEye%20(1995)            |
|          3 | Four Rooms (1995)                                    | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Four%20Rooms%20(1995)         |
|          4 | Get Shorty (1995)                                    | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Get%20Shorty%20(1995)         |
|          5 | Copycat (1995)                                       | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Copycat%20(1995)              |
|          6 | Shanghai Triad (Yao a yao yao dao waipo qiao) (1995) | 01-Jan-1995    |                      | http://us.imdb.com/Title?Yao+a+yao+yao+dao+waipo+qiao+(1995)   |
|          7 | Twelve Monkeys (1995)                                | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Twelve%20Monkeys%20(1995)     |
|          8 | Babe (1995)                                          | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Babe%20(1995)                 |
|          9 | Dead Man Walking (1995)                              | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Dead%20Man%20Walking%20(1995) |
|         10 | Richard III (1995)                                   | 22-Jan-1996    |                      | http://us.imdb.com/M/title-exact?Richard%20III%20(1995)        |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   user_id |   movie_id |   rating |   unix_timestamp |
|----------:|-----------:|---------:|-----------------:|
|       110 |         63 |        3 |      8.86989e+08 |
|       632 |        204 |        4 |      8.79458e+08 |
|       893 |        220 |        3 |      8.74829e+08 |
|       704 |        496 |        5 |      8.91398e+08 |
|        38 |        406 |        2 |      8.92434e+08 |
|       788 |        568 |        3 |      8.8087e+08  |
|       256 |       1471 |        3 |      8.82165e+08 |
|       699 |        717 |        1 |      8.78883e+08 |
|       588 |        354 |        5 |      8.90015e+08 |
|       802 |        674 |        2 |      8.75986e+08 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|   user_id |   age | sex   | occupation    |   zip_code |
|----------:|------:|:------|:--------------|-----------:|
|         1 |    24 | M     | technician    |      85711 |
|         2 |    53 | F     | other         |      94043 |
|         3 |    23 | M     | writer        |      32067 |
|         4 |    24 | M     | technician    |      43537 |
|         5 |    33 | F     | other         |      15213 |
|         6 |    42 | M     | executive     |      98101 |
|         7 |    57 | M     | administrator |      91344 |
|         8 |    36 | M     | administrator |      05201 |
|         9 |    29 | M     | student       |      01002 |
|        10 |    53 | M     | lawyer        |      90703 |


Target Schema:
|   movie_id | title                                                |       F |       M |
|-----------:|:-----------------------------------------------------|--------:|--------:|
|          1 | Toy Story (1995)                                     | 3.85714 | 3.86184 |
|          2 | GoldenEye (1995)                                     | 3.125   | 3.03922 |
|          3 | Four Rooms (1995)                                    | 2.875   | 3.20513 |
|          4 | Get Shorty (1995)                                    | 3.59091 | 3.62667 |
|          5 | Copycat (1995)                                       | 3.78571 | 3.17647 |
|          6 | Shanghai Triad (Yao a yao yao dao waipo qiao) (1995) | 3.66667 | 3.72727 |
|          7 | Twelve Monkeys (1995)                                | 3.4898  | 3.85714 |
|          8 | Babe (1995)                                          | 4.28571 | 3.95294 |
|          9 | Dead Man Walking (1995)                              | 4.09524 | 3.93407 |
|         10 | Richard III (1995)                                   | 3.27273 | 3.78571 |

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