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 |   item_id |   rating |   timestamp |
|----------:|----------:|---------:|------------:|
|       846 |       198 |        5 | 8.83948e+08 |
|       846 |       568 |        4 | 8.83949e+08 |
|       117 |      1059 |        3 | 8.81009e+08 |
|       881 |       434 |        2 | 8.76539e+08 |
|       434 |         1 |        4 | 8.86725e+08 |
|       566 |       170 |        5 | 8.81651e+08 |
|       694 |       705 |        5 | 8.75728e+08 |
|       588 |      1411 |        1 | 8.90032e+08 |
|       833 |       381 |        4 | 8.75134e+08 |
|       870 |       169 |        4 | 8.88096e+08 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   item_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 |


Target Schema:
|   user_id |   item_id |   rating |   timestamp | movie title   |
|----------:|----------:|---------:|------------:|:--------------|
|       196 |       242 |        3 |   881250949 | Kolya (1996)  |
|        63 |       242 |        3 |   875747190 | Kolya (1996)  |
|       226 |       242 |        5 |   883888671 | Kolya (1996)  |
|       154 |       242 |        3 |   879138235 | Kolya (1996)  |
|       306 |       242 |        5 |   876503793 | Kolya (1996)  |
|       296 |       242 |        4 |   884196057 | Kolya (1996)  |
|        34 |       242 |        5 |   888601628 | Kolya (1996)  |
|       271 |       242 |        4 |   885844495 | Kolya (1996)  |
|       201 |       242 |        4 |   884110598 | Kolya (1996)  |
|       209 |       242 |        4 |   883589606 | Kolya (1996)  |

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
test: test_0.csv
test_1.csv