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:
|   userId |   movieId | tag                     |   timestamp |
|---------:|----------:|:------------------------|------------:|
|       15 |       339 | sandra 'boring' bullock |  1138537770 |
|       15 |      1955 | dentist                 |  1193435061 |
|       15 |      7478 | Cambodia                |  1170560997 |
|       15 |     32892 | Russian                 |  1170626366 |
|       15 |     34162 | forgettable             |  1141391765 |
|       15 |     35957 | short                   |  1141391873 |
|       15 |     37729 | dull story              |  1141391806 |
|       15 |     45950 | powerpoint              |  1169616291 |
|       15 |    100365 | activist                |  1425876220 |
|       15 |    100365 | documentary             |  1425876220 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   movieId | title                                                            | genres                           |
|----------:|:-----------------------------------------------------------------|:---------------------------------|
|      7301 | Diary of a Country Priest (Journal d'un curé de campagne) (1951) | Drama                            |
|      7302 | Thief of Bagdad, The (1924)                                      | Action|Adventure|Fantasy         |
|      7303 | The Diary of Anne Frank (1959)                                   | Drama|War                        |
|      7304 | Allegro non troppo (1977)                                        | Animation|Comedy|Fantasy|Musical |
|      7305 | Black Widow (1987)                                               | Crime|Drama|Mystery|Thriller     |
|      7306 | Herod's Law (Ley de Herodes, La) (2000)                          | Comedy|Crime|Mystery             |
|      7307 | Flesh & Blood (1985)                                             | Action|Adventure|Drama|War       |
|      7308 | King Solomon's Mines (1985)                                      | Adventure|Comedy                 |
|      7310 | Raw Deal (1986)                                                  | Action                           |
|      7311 | Goodbye, Mr. Chips (1939)                                        | Drama|Romance                    |


Target Schema:
|   movieId | title                              | genres                                      |   userId | tag           |   timestamp |
|----------:|:-----------------------------------|:--------------------------------------------|---------:|:--------------|------------:|
|         1 | Toy Story (1995)                   | Adventure|Animation|Children|Comedy|Fantasy |      501 | Pixar         |  1292956344 |
|         5 | Father of the Bride Part II (1995) | Comedy                                      |      431 | steve martin  |  1140455432 |
|        47 | Seven (a.k.a. Se7en) (1995)        | Mystery|Thriller                            |      364 | biblical      |  1444534976 |
|        47 | Seven (a.k.a. Se7en) (1995)        | Mystery|Thriller                            |      364 | crime         |  1444534982 |
|        47 | Seven (a.k.a. Se7en) (1995)        | Mystery|Thriller                            |      364 | dark          |  1444534994 |
|        47 | Seven (a.k.a. Se7en) (1995)        | Mystery|Thriller                            |      364 | disturbing    |  1444534971 |
|        47 | Seven (a.k.a. Se7en) (1995)        | Mystery|Thriller                            |      364 | greed         |  1444534998 |
|        47 | Seven (a.k.a. Se7en) (1995)        | Mystery|Thriller                            |      364 | horror        |  1444534981 |
|        47 | Seven (a.k.a. Se7en) (1995)        | Mystery|Thriller                            |      364 | serial killer |  1444534961 |
|        47 | Seven (a.k.a. Se7en) (1995)        | Mystery|Thriller                            |      364 | violent       |  1444534985 |

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