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:
|   tripduration | starttime                | stoptime                 |   start station id | start station name   |   start station latitude |   start station longitude |   end station id | end station name   |   end station latitude |   end station longitude |   bikeid | usertype   |   birth year |   gender |
|---------------:|:-------------------------|:-------------------------|-------------------:|:---------------------|-------------------------:|--------------------------:|-----------------:|:-------------------|-----------------------:|------------------------:|---------:|:-----------|-------------:|---------:|
|            215 | 2018-04-24 12:00:10.4830 | 2018-04-24 12:03:46.4030 |               3203 | Hamilton Park        |                  40.7276 |                  -74.0442 |             3211 | Newark Ave         |                40.7215 |                -74.0463 |    29674 | Subscriber |         1989 |        2 |
|           1913 | 2018-04-24 12:03:28.9320 | 2018-04-24 12:35:22.4880 |               3203 | Hamilton Park        |                  40.7276 |                  -74.0442 |             3203 | Hamilton Park      |                40.7276 |                -74.0442 |    33569 | Subscriber |         1980 |        1 |
|           2296 | 2018-04-24 12:06:32.3030 | 2018-04-24 12:44:48.5760 |               3203 | Hamilton Park        |                  40.7276 |                  -74.0442 |             3185 | City Hall          |                40.7177 |                -74.0438 |    33618 | Subscriber |         1958 |        1 |
|            329 | 2018-04-24 12:20:30.2130 | 2018-04-24 12:25:59.7580 |               3203 | Hamilton Park        |                  40.7276 |                  -74.0442 |             3199 | Newport Pkwy       |                40.7287 |                -74.0321 |    32435 | Subscriber |         1969 |        0 |
|            311 | 2018-04-24 12:20:43.0160 | 2018-04-24 12:25:54.4260 |               3203 | Hamilton Park        |                  40.7276 |                  -74.0442 |             3199 | Newport Pkwy       |                40.7287 |                -74.0321 |    29666 | Subscriber |         1985 |        1 |
|            373 | 2018-04-24 13:18:35.0760 | 2018-04-24 13:24:48.5450 |               3203 | Hamilton Park        |                  40.7276 |                  -74.0442 |             3186 | Grove St PATH      |                40.7196 |                -74.0431 |    33569 | Subscriber |         1984 |        2 |
|            342 | 2018-04-24 13:45:01.0160 | 2018-04-24 13:50:43.7380 |               3203 | Hamilton Park        |                  40.7276 |                  -74.0442 |             3185 | City Hall          |                40.7177 |                -74.0438 |    29256 | Subscriber |         1956 |        1 |
|            531 | 2018-04-24 15:07:29.1790 | 2018-04-24 15:16:20.4540 |               3203 | Hamilton Park        |                  40.7276 |                  -74.0442 |             3186 | Grove St PATH      |                40.7196 |                -74.0431 |    33590 | Subscriber |         1989 |        1 |
|            301 | 2018-04-24 15:12:59.2590 | 2018-04-24 15:18:00.2720 |               3203 | Hamilton Park        |                  40.7276 |                  -74.0442 |             3187 | Warren St          |                40.7211 |                -74.0381 |    29245 | Subscriber |         1991 |        1 |
|            349 | 2018-04-24 16:01:31.9640 | 2018-04-24 16:07:21.7700 |               3203 | Hamilton Park        |                  40.7276 |                  -74.0442 |             3186 | Grove St PATH      |                40.7196 |                -74.0431 |    29603 | Subscriber |         1980 |        1 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   tripduration | starttime                | stoptime                 |   start station id | start station name   |   start station latitude |   start station longitude |   end station id | end station name   |   end station latitude |   end station longitude |   bikeid | usertype   |   birth year |   gender |
|---------------:|:-------------------------|:-------------------------|-------------------:|:---------------------|-------------------------:|--------------------------:|-----------------:|:-------------------|-----------------------:|------------------------:|---------:|:-----------|-------------:|---------:|
|            329 | 2018-03-01 06:37:37.0380 | 2018-03-01 06:43:06.5520 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3202 | Newport PATH       |                40.7272 |                -74.0338 |    29284 | Subscriber |         1981 |        1 |
|            118 | 2018-03-01 07:37:30.1210 | 2018-03-01 07:39:28.3910 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3184 | Paulus Hook        |                40.7141 |                -74.0336 |    29465 | Subscriber |         1966 |        1 |
|             76 | 2018-03-01 08:26:17.9390 | 2018-03-01 08:27:34.6770 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3184 | Paulus Hook        |                40.7141 |                -74.0336 |    29681 | Subscriber |         1975 |        1 |
|            578 | 2018-03-01 12:10:36.2160 | 2018-03-01 12:20:14.8690 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3185 | City Hall          |                40.7177 |                -74.0438 |    31695 | Subscriber |         1970 |        1 |
|            485 | 2018-03-01 12:21:47.8800 | 2018-03-01 12:29:53.2990 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3187 | Warren St          |                40.7211 |                -74.0381 |    31802 | Subscriber |         1979 |        1 |
|            352 | 2018-03-01 13:11:22.7530 | 2018-03-01 13:17:15.1130 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3202 | Newport PATH       |                40.7272 |                -74.0338 |    31934 | Subscriber |         1974 |        1 |
|            450 | 2018-03-01 13:33:52.9640 | 2018-03-01 13:41:23.6750 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3183 | Exchange Place     |                40.7162 |                -74.0335 |    29244 | Subscriber |         1984 |        1 |
|            307 | 2018-03-01 14:26:33.5640 | 2018-03-01 14:31:41.1030 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3481 | York St            |                40.7165 |                -74.041  |    31811 | Subscriber |         1968 |        2 |
|            263 | 2018-03-01 14:31:28.8290 | 2018-03-01 14:35:52.5940 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3213 | Van Vorst Park     |                40.7185 |                -74.0477 |    26247 | Subscriber |         1986 |        1 |
|            238 | 2018-03-01 16:41:05.2790 | 2018-03-01 16:45:04.2770 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3267 | Morris Canal       |                40.7124 |                -74.0385 |    31828 | Subscriber |         1974 |        1 |


Target Schema:
|   tripduration | starttime                | stoptime                 |   start station id | start station name   |   start station latitude |   start station longitude |   end station id | end station name   |   end station latitude |   end station longitude |   bikeid | usertype   |   birth year |   gender |
|---------------:|:-------------------------|:-------------------------|-------------------:|:---------------------|-------------------------:|--------------------------:|-----------------:|:-------------------|-----------------------:|------------------------:|---------:|:-----------|-------------:|---------:|
|            329 | 2018-03-01 06:37:37.0380 | 2018-03-01 06:43:06.5520 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3202 | Newport PATH       |                40.7272 |                -74.0338 |    29284 | Subscriber |         1981 |        1 |
|            118 | 2018-03-01 07:37:30.1210 | 2018-03-01 07:39:28.3910 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3184 | Paulus Hook        |                40.7141 |                -74.0336 |    29465 | Subscriber |         1966 |        1 |
|             76 | 2018-03-01 08:26:17.9390 | 2018-03-01 08:27:34.6770 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3184 | Paulus Hook        |                40.7141 |                -74.0336 |    29681 | Subscriber |         1975 |        1 |
|            578 | 2018-03-01 12:10:36.2160 | 2018-03-01 12:20:14.8690 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3185 | City Hall          |                40.7177 |                -74.0438 |    31695 | Subscriber |         1970 |        1 |
|            485 | 2018-03-01 12:21:47.8800 | 2018-03-01 12:29:53.2990 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3187 | Warren St          |                40.7211 |                -74.0381 |    31802 | Subscriber |         1979 |        1 |
|            352 | 2018-03-01 13:11:22.7530 | 2018-03-01 13:17:15.1130 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3202 | Newport PATH       |                40.7272 |                -74.0338 |    31934 | Subscriber |         1974 |        1 |
|            450 | 2018-03-01 13:33:52.9640 | 2018-03-01 13:41:23.6750 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3183 | Exchange Place     |                40.7162 |                -74.0335 |    29244 | Subscriber |         1984 |        1 |
|            307 | 2018-03-01 14:26:33.5640 | 2018-03-01 14:31:41.1030 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3481 | York St            |                40.7165 |                -74.041  |    31811 | Subscriber |         1968 |        2 |
|            263 | 2018-03-01 14:31:28.8290 | 2018-03-01 14:35:52.5940 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3213 | Van Vorst Park     |                40.7185 |                -74.0477 |    26247 | Subscriber |         1986 |        1 |
|            238 | 2018-03-01 16:41:05.2790 | 2018-03-01 16:45:04.2770 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3267 | Morris Canal       |                40.7124 |                -74.0385 |    31828 | Subscriber |         1974 |        1 |

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