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 | timestamp           | source         | device   | operative_system   |   test |   price |   converted |
|----------:|:--------------------|:---------------|:---------|:-------------------|-------:|--------:|------------:|
|    798367 | 2015-05-20 15:06:03 | ads-yahoo      | web      | mac                |      1 |      59 |           0 |
|    497447 | 2015-03-17 17:37:41 | ads-google     | mobile   | iOS                |      1 |      59 |           0 |
|    263612 | 2015-04-25 16:52:23 | direct_traffic | mobile   | iOS                |      0 |      39 |           0 |
|    808534 | 2015-03-20 10:18:06 | ads-google     | web      | windows            |      1 |      59 |           1 |
|    424802 | 2015-05-15 17:26:22 | ads-yahoo      | web      | mac                |      0 |      39 |           0 |
|    254694 | 2015-04-17 15:45:05 | direct_traffic | web      | windows            |      0 |      39 |           0 |
|    850688 | 2015-05-17 12:57:20 | ads-google     | mobile   | iOS                |      1 |      59 |           0 |
|    425469 | 2015-04-12 10:54:32 | ads_other      | web      | windows            |      0 |      39 |           0 |
|    293968 | 2015-04-30 08:38:31 | ads_facebook   | mobile   | other              |      0 |      39 |           0 |
|    520898 | 2015-03-06 19:35:45 | ads_facebook   | mobile   | android            |      1 |      59 |           0 |


Target Schema:
|   user_id | timestamp           | source       | device   | operative_system   |   test |   price |   converted |
|----------:|:--------------------|:-------------|:---------|:-------------------|-------:|--------:|------------:|
|    639459 | 2015-05-02 13:45:32 | ads_facebook | mobile   | iOS                |      0 |      39 |           0 |
|    285124 | 2015-03-26 18:28:13 | seo-google   | mobile   | other              |      1 |      59 |           0 |
|    275927 | 2015-03-13 07:06:45 | seo-google   | web      | windows            |      0 |      39 |           0 |
|    884497 | 2015-05-30 13:39:43 | ads-yahoo    | mobile   | android            |      0 |      39 |           0 |
|    818525 | 2015-04-05 12:57:23 | ads-google   | mobile   | iOS                |      1 |      59 |           0 |
|    995021 | 2015-04-18 12:27:28 | seo-google   | mobile   | iOS                |      1 |      59 |           0 |
|    350064 | 2015-05-02 23:42:54 | ads-google   | mobile   | other              |      0 |      39 |           0 |
|     79411 | 2015-04-03 17:57:55 | ads-bing     | web      | windows            |      1 |      59 |           0 |
|    376887 | 2015-05-08 22:03:34 | seo-google   | web      | windows            |      1 |      59 |           0 |
|    438235 | 2015-05-22 12:25:26 | ads_other    | web      | windows            |      0 |      39 |           0 |

Return only the final code in markdown codeblock format, without any additional text or explanation. 



target: target.csv
train: source_0.csv
test: test_0.csv