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 |
|----------:|:--------------------|:---------------|:---------|:-------------------|-------:|--------:|------------:|
|    601047 | 2015-05-05 08:07:22 | ads-google     | mobile   | iOS                |      0 |      39 |           0 |
|    653947 | 2015-05-16 00:02:15 | ads_other      | web      | linux              |      0 |      39 |           0 |
|    456104 | 2015-04-09 18:22:21 | direct_traffic | mobile   | iOS                |      0 |      39 |           0 |
|    790005 | 2015-05-09 12:35:48 | seo-google     | mobile   | android            |      0 |      39 |           0 |
|    915987 | 2015-04-20 15:52:28 | seo-google     | mobile   | android            |      0 |      39 |           0 |
|     88302 | 2015-05-02 00:52:46 | seo_facebook   | web      | windows            |      1 |      59 |           0 |
|    473452 | 2015-03-10 01:34:27 | seo-google     | web      | windows            |      1 |      59 |           0 |
|    210351 | 2015-05-03 13:58:13 | seo-google     | mobile   | android            |      0 |      39 |           0 |
|     28176 | 2015-03-06 11:28:46 | ads-bing       | mobile   | android            |      1 |      59 |           0 |
|    138456 | 2015-04-05 09:36:46 | direct_traffic | mobile   | iOS                |      1 |      59 |           0 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   user_id | city             | country   |   lat |    long |
|----------:|:-----------------|:----------|------:|--------:|
|    129408 | Sioux City       | USA       | 42.5  |  -96.39 |
|     78453 | Beaverton        | USA       | 45.48 | -122.82 |
|    689773 | Pensacola        | USA       | 30.44 |  -87.19 |
|    387633 | Hamilton         | USA       | 40.09 |  -74.39 |
|    727684 | Joliet           | USA       | 41.53 |  -88.12 |
|    176677 | Los Angeles      | USA       | 34.11 | -118.41 |
|    266565 | Saint Petersburg | USA       | 59.93 |  -82.64 |
|    668332 | Roswell          | USA       | 33.37 | -104.53 |
|    636691 | Daytona Beach    | USA       | 29.19 |  -81.05 |
|    692980 | East Providence  | USA       | 41.8  |  -71.36 |


Target Schema:
|   user_id | timestamp           | source       | device   | operative_system   |   test |   price |   converted | city         |
|----------:|:--------------------|:-------------|:---------|:-------------------|-------:|--------:|------------:|:-------------|
|     99856 | 2015-04-05 14:06:16 | ads-google   | mobile   | android            |      1 |      59 |           0 | Lexington    |
|     99856 | 2015-04-05 14:06:16 | ads-google   | mobile   | android            |      1 |      59 |           0 | Lexington    |
|    566389 | 2015-04-17 18:19:21 | seo_facebook | mobile   | android            |      0 |      39 |           0 | Fort Worth   |
|    566389 | 2015-04-17 18:19:21 | seo_facebook | mobile   | android            |      0 |      39 |           0 | Fort Worth   |
|    239513 | 2015-03-27 11:52:57 | ads_other    | mobile   | android            |      1 |      59 |           0 | Indianapolis |
|    239513 | 2015-03-27 11:52:57 | ads_other    | mobile   | android            |      1 |      59 |           0 | Indianapolis |
|    221491 | 2015-04-30 20:21:43 | ads-yahoo    | mobile   | iOS                |      0 |      39 |           0 | Atlanta      |
|    221491 | 2015-04-30 20:21:43 | ads-yahoo    | mobile   | iOS                |      0 |      39 |           0 | Atlanta      |
|    832413 | 2015-04-26 15:07:26 | ads_facebook | web      | mac                |      0 |      39 |           0 | Reno         |
|    832413 | 2015-04-26 15:07:26 | ads_facebook | web      | mac                |      0 |      39 |           0 | Reno         |

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