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


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   user_id |   movie_id |   rating |   unix_timestamp |
|----------:|-----------:|---------:|-----------------:|
|       424 |        259 |        2 |      8.80859e+08 |
|       504 |        725 |        3 |      8.87912e+08 |
|       194 |        516 |        3 |      8.79522e+08 |
|       692 |        168 |        2 |      8.76953e+08 |
|       887 |       1035 |        5 |      8.81382e+08 |
|       721 |        872 |        3 |      8.77138e+08 |
|       650 |       1149 |        4 |      8.91384e+08 |
|       654 |        568 |        4 |      8.87865e+08 |
|       682 |        585 |        4 |      8.88522e+08 |
|       302 |        266 |        2 |      8.79437e+08 |


Table #3
Filename: source_2.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)        |


Target Schema:
|   movie_id |   0 |
|-----------:|----:|
|          1 | 208 |
|          2 |  59 |
|          3 |  47 |
|          4 |  97 |
|          5 |  48 |
|          6 |  14 |
|          7 | 203 |
|          8 | 113 |
|          9 | 133 |
|         10 |  39 |

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