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


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   userId |   movieId |   rating |   timestamp |
|---------:|----------:|---------:|------------:|
|      517 |        11 |      5   | 8.4645e+08  |
|      559 |      2431 |      4   | 9.17731e+08 |
|      469 |     72612 |      2.5 | 1.28247e+09 |
|      391 |      1131 |      4   | 8.91533e+08 |
|      575 |       497 |      5   | 1.01259e+09 |
|      580 |      2723 |      3   | 1.16716e+09 |
|      519 |     48385 |      4.5 | 1.46876e+09 |
|      587 |      6993 |      4.5 | 1.11136e+09 |
|      405 |      2747 |      3.5 | 1.06136e+09 |
|      646 |         1 |      5   | 9.5345e+08  |


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