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 |   rating |   timestamp |
|---------:|----------:|---------:|------------:|
|      472 |      4993 |      3   | 1.01044e+09 |
|      582 |      1441 |      4   | 1.12217e+09 |
|      431 |     36517 |      5   | 1.16555e+09 |
|      475 |     96691 |      2   | 1.44726e+09 |
|      410 |       356 |      5   | 1.43406e+09 |
|      518 |      1854 |      4   | 9.45362e+08 |
|      452 |      3173 |      2   | 1.00294e+09 |
|      571 |      3535 |      4.5 | 1.33434e+09 |
|      380 |     41569 |      3.5 | 1.15549e+09 |
|      520 |     44191 |      3.5 | 1.1435e+09  |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   movieId | title                              | genres                                      |
|----------:|:-----------------------------------|:--------------------------------------------|
|         1 | Toy Story (1995)                   | Adventure|Animation|Children|Comedy|Fantasy |
|         2 | Jumanji (1995)                     | Adventure|Children|Fantasy                  |
|         3 | Grumpier Old Men (1995)            | Comedy|Romance                              |
|         4 | Waiting to Exhale (1995)           | Comedy|Drama|Romance                        |
|         5 | Father of the Bride Part II (1995) | Comedy                                      |
|         6 | Heat (1995)                        | Action|Crime|Thriller                       |
|         7 | Sabrina (1995)                     | Comedy|Romance                              |
|         8 | Tom and Huck (1995)                | Adventure|Children                          |
|         9 | Sudden Death (1995)                | Action                                      |
|        10 | GoldenEye (1995)                   | Action|Adventure|Thriller                   |


Target Schema:
|   userId |   movieId |   rating |   timestamp | title                  | genres   | genres_arr   | genre_count   |
|---------:|----------:|---------:|------------:|:-----------------------|:---------|:-------------|:--------------|
|        1 |        31 |      2.5 |  1260759144 | Dangerous Minds (1995) | Drama    | ['Drama']    | Drama         |
|        7 |        31 |      3   |   851868750 | Dangerous Minds (1995) | Drama    | ['Drama']    | Drama         |
|       31 |        31 |      4   |  1273541953 | Dangerous Minds (1995) | Drama    | ['Drama']    | Drama         |
|       32 |        31 |      4   |   834828440 | Dangerous Minds (1995) | Drama    | ['Drama']    | Drama         |
|       36 |        31 |      3   |   847057202 | Dangerous Minds (1995) | Drama    | ['Drama']    | Drama         |
|       39 |        31 |      3   |   832525157 | Dangerous Minds (1995) | Drama    | ['Drama']    | Drama         |
|       73 |        31 |      3.5 |  1255591860 | Dangerous Minds (1995) | Drama    | ['Drama']    | Drama         |
|       88 |        31 |      3   |  1239755559 | Dangerous Minds (1995) | Drama    | ['Drama']    | Drama         |
|       96 |        31 |      2.5 |  1223256331 | Dangerous Minds (1995) | Drama    | ['Drama']    | Drama         |
|      110 |        31 |      4   |   840100695 | Dangerous Minds (1995) | Drama    | ['Drama']    | Drama         |

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