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:
| city          |   driver_count | type   |
|:--------------|---------------:|:-------|
| Richardfort   |             38 | Urban  |
| Williamsstad  |             59 | Urban  |
| Port Angela   |             67 | Urban  |
| Rodneyfort    |             34 | Urban  |
| West Robert   |             39 | Urban  |
| West Anthony  |             70 | Urban  |
| West Angela   |             48 | Urban  |
| Martinezhaven |             25 | Urban  |
| Karenberg     |             22 | Urban  |
| Barajasview   |             26 | Urban  |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| city                | date                |   fare |       ride_id |
|:--------------------|:--------------------|-------:|--------------:|
| Leahton             | 2018-02-28 20:02:59 |  31.01 | 2116500207936 |
| Johnton             | 2018-04-11 14:40:12 |  16.63 | 7248459450448 |
| Port David          | 2018-01-21 02:29:36 |  32.92 |  857956984195 |
| New Kimberlyborough | 2018-04-01 04:31:44 |  35.11 | 8275820093507 |
| Port Frank          | 2018-02-26 05:03:19 |  25.18 | 7280804922163 |
| Barajasview         | 2018-01-24 05:58:33 |   9.21 | 1841073494391 |
| South Phillip       | 2018-04-21 10:31:27 |  32.85 | 2752328490329 |
| North Jasmine       | 2018-04-03 13:15:16 |  19.66 | 9206122228723 |
| New Kimberlyborough | 2018-03-13 09:48:42 |  14.84 | 1839171122889 |
| North Jasmine       | 2018-01-05 16:39:33 |  26.72 | 3669060555225 |


Target Schema:
| city          |   driver_count | type   |   Average Fare |   Ride Count |
|:--------------|---------------:|:-------|---------------:|-------------:|
| Richardfort   |             38 | Urban  |        23.9237 |           16 |
| Williamsstad  |             59 | Urban  |        25.2142 |           19 |
| Port Angela   |             67 | Urban  |        24.9387 |           16 |
| Rodneyfort    |             34 | Urban  |        28.2909 |           22 |
| West Robert   |             39 | Urban  |        22.5304 |           23 |
| West Anthony  |             70 | Urban  |        24.4228 |           25 |
| West Angela   |             48 | Urban  |        25.6772 |           29 |
| Martinezhaven |             25 | Urban  |        21.1928 |           18 |
| Karenberg     |             22 | Urban  |        28.5715 |           13 |
| Barajasview   |             26 | Urban  |        28.7544 |           16 |

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