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 |   age | gender   | 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 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   movie id | movie title                                          | release date   | video release date   | IMDb URL                                                       |   unknown |   Action |   Adventure |   Animation |   Childrens |   Comedy |   Crime |   Documentary |   Drama |   Fantasy |   Film-Noir |   Horror |   Musical |   Mystery |   Romance  |   Sci-Fi |   Thriller |   War |   Western |
|-----------:|:-----------------------------------------------------|:---------------|:---------------------|:---------------------------------------------------------------|----------:|---------:|------------:|------------:|------------:|---------:|--------:|--------------:|--------:|----------:|------------:|---------:|----------:|----------:|-----------:|---------:|-----------:|------:|----------:|
|          1 | Toy Story (1995)                                     | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Toy%20Story%20(1995)          |         0 |        0 |           0 |           1 |           1 |        1 |       0 |             0 |       0 |         0 |           0 |        0 |         0 |         0 |          0 |        0 |          0 |     0 |         0 |
|          2 | GoldenEye (1995)                                     | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?GoldenEye%20(1995)            |         0 |        1 |           1 |           0 |           0 |        0 |       0 |             0 |       0 |         0 |           0 |        0 |         0 |         0 |          0 |        0 |          1 |     0 |         0 |
|          3 | Four Rooms (1995)                                    | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Four%20Rooms%20(1995)         |         0 |        0 |           0 |           0 |           0 |        0 |       0 |             0 |       0 |         0 |           0 |        0 |         0 |         0 |          0 |        0 |          1 |     0 |         0 |
|          4 | Get Shorty (1995)                                    | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Get%20Shorty%20(1995)         |         0 |        1 |           0 |           0 |           0 |        1 |       0 |             0 |       1 |         0 |           0 |        0 |         0 |         0 |          0 |        0 |          0 |     0 |         0 |
|          5 | Copycat (1995)                                       | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Copycat%20(1995)              |         0 |        0 |           0 |           0 |           0 |        0 |       1 |             0 |       1 |         0 |           0 |        0 |         0 |         0 |          0 |        0 |          1 |     0 |         0 |
|          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)   |         0 |        0 |           0 |           0 |           0 |        0 |       0 |             0 |       1 |         0 |           0 |        0 |         0 |         0 |          0 |        0 |          0 |     0 |         0 |
|          7 | Twelve Monkeys (1995)                                | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Twelve%20Monkeys%20(1995)     |         0 |        0 |           0 |           0 |           0 |        0 |       0 |             0 |       1 |         0 |           0 |        0 |         0 |         0 |          0 |        1 |          0 |     0 |         0 |
|          8 | Babe (1995)                                          | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Babe%20(1995)                 |         0 |        0 |           0 |           0 |           1 |        1 |       0 |             0 |       1 |         0 |           0 |        0 |         0 |         0 |          0 |        0 |          0 |     0 |         0 |
|          9 | Dead Man Walking (1995)                              | 01-Jan-1995    |                      | http://us.imdb.com/M/title-exact?Dead%20Man%20Walking%20(1995) |         0 |        0 |           0 |           0 |           0 |        0 |       0 |             0 |       1 |         0 |           0 |        0 |         0 |         0 |          0 |        0 |          0 |     0 |         0 |
|         10 | Richard III (1995)                                   | 22-Jan-1996    |                      | http://us.imdb.com/M/title-exact?Richard%20III%20(1995)        |         0 |        0 |           0 |           0 |           0 |        0 |       0 |             0 |       1 |         0 |           0 |        0 |         0 |         0 |          0 |        0 |          0 |     1 |         0 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|   user id |   movie id |   rating |   timestamp |
|----------:|-----------:|---------:|------------:|
|       132 |        100 |        4 | 8.91279e+08 |
|       592 |        116 |        4 | 8.82608e+08 |
|       513 |        685 |        4 | 8.85063e+08 |
|       925 |        327 |        3 | 8.84718e+08 |
|       291 |         98 |        5 | 8.74835e+08 |
|       940 |        482 |        5 | 8.85921e+08 |
|       782 |        253 |        2 | 8.915e+08   |
|       570 |        305 |        5 | 8.81262e+08 |
|       727 |        366 |        3 | 8.83712e+08 |
|       283 |         91 |        5 | 8.79298e+08 |


Target Schema:
| movie title                                 |   rating |
|:--------------------------------------------|---------:|
| 'Til There Was You (1997)                   |  2.33333 |
| 1-900 (1994)                                |  2.5     |
| 101 Dalmatians (1996)                       |  2.94231 |
| 12 Angry Men (1957)                         |  4.31148 |
| 187 (1997)                                  |  2.88889 |
| 2 Days in the Valley (1996)                 |  3.25641 |
| 20,000 Leagues Under the Sea (1954)         |  3.48387 |
| 2001: A Space Odyssey (1968)                |  4.08594 |
| 3 Ninjas: High Noon At Mega Mountain (1998) |  1       |
| 39 Steps, The (1935)                        |  4       |

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