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 |
|---------------:|:-------------------------|:-------------------------|-------------------:|:---------------------|-------------------------:|--------------------------:|-----------------:|:-------------------|-----------------------:|------------------------:|---------:|:-----------|-------------:|---------:|
|            142 | 2019-02-01 15:35:02.0820 | 2019-02-01 15:37:24.1360 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3639 | Harborside         |                40.7193 |                -74.0342 |    29677 | Subscriber |         1963 |        1 |
|            223 | 2019-02-01 17:00:46.8900 | 2019-02-01 17:04:30.5500 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3681 | Grand St           |                40.7152 |                -74.0377 |    26234 | Subscriber |         1992 |        2 |
|            106 | 2019-02-01 17:08:01.3260 | 2019-02-01 17:09:47.4400 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3184 | Paulus Hook        |                40.7141 |                -74.0336 |    29588 | Subscriber |         1960 |        1 |
|            370 | 2019-02-01 17:09:31.2100 | 2019-02-01 17:15:41.6550 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3211 | Newark Ave         |                40.7215 |                -74.0463 |    29250 | Subscriber |         1976 |        1 |
|            315 | 2019-02-01 17:19:53.2490 | 2019-02-01 17:25:09.1400 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3273 | Manila & 1st       |                40.7217 |                -74.0429 |    29586 | Subscriber |         1980 |        1 |
|            145 | 2019-02-01 17:32:53.2630 | 2019-02-01 17:35:18.7510 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3214 | Essex Light Rail   |                40.7128 |                -74.0365 |    26153 | Subscriber |         1984 |        1 |
|           1625 | 2019-02-01 17:39:55.5390 | 2019-02-01 18:07:01.2660 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3186 | Grove St PATH      |                40.7196 |                -74.0431 |    29242 | Subscriber |         1993 |        1 |
|            485 | 2019-02-01 17:46:32.7540 | 2019-02-01 17:54:37.9890 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3186 | Grove St PATH      |                40.7196 |                -74.0431 |    29496 | Subscriber |         1970 |        1 |
|            632 | 2019-02-01 18:05:26.8150 | 2019-02-01 18:15:59.1050 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3278 | Monmouth and 6th   |                40.7257 |                -74.0488 |    26307 | Customer   |         1981 |        1 |
|            235 | 2019-02-01 18:11:06.8410 | 2019-02-01 18:15:02.7810 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3681 | Grand St           |                40.7152 |                -74.0377 |    26293 | Subscriber |         1982 |        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 |
|---------------:|:-------------------------|:-------------------------|-------------------:|:---------------------|-------------------------:|--------------------------:|-----------------:|:-------------------|-----------------------:|------------------------:|---------:|:-----------|-------------:|---------:|
|            503 | 2019-01-26 16:00:18.0310 | 2019-01-26 16:08:41.4240 |               3207 | Oakland Ave          |                  40.7376 |                  -74.0525 |             3209 | Brunswick St       |                40.7242 |                -74.0507 |    26267 | Subscriber |         1989 |        2 |
|          30998 | 2019-01-27 06:59:08.7260 | 2019-01-27 15:35:47.1320 |               3207 | Oakland Ave          |                  40.7376 |                  -74.0525 |             3195 | Sip Ave            |                40.7307 |                -74.0638 |    26300 | Customer   |         1969 |        0 |
|            347 | 2019-01-27 09:46:35.6450 | 2019-01-27 09:52:22.8890 |               3207 | Oakland Ave          |                  40.7376 |                  -74.0525 |             3195 | Sip Ave            |                40.7307 |                -74.0638 |    29612 | Subscriber |         1994 |        1 |
|            494 | 2019-01-27 11:26:33.7510 | 2019-01-27 11:34:48.7180 |               3207 | Oakland Ave          |                  40.7376 |                  -74.0525 |             3198 | Heights Elevator   |                40.7487 |                -74.0404 |    29216 | Subscriber |         1969 |        0 |
|            415 | 2019-01-27 11:27:49.0750 | 2019-01-27 11:34:44.5860 |               3207 | Oakland Ave          |                  40.7376 |                  -74.0525 |             3198 | Heights Elevator   |                40.7487 |                -74.0404 |    29483 | Subscriber |         1987 |        1 |
|            299 | 2019-01-27 11:44:43.2050 | 2019-01-27 11:49:42.8260 |               3207 | Oakland Ave          |                  40.7376 |                  -74.0525 |             3195 | Sip Ave            |                40.7307 |                -74.0638 |    29273 | Subscriber |         1985 |        1 |
|            984 | 2019-01-27 14:38:21.0290 | 2019-01-27 14:54:45.5200 |               3207 | Oakland Ave          |                  40.7376 |                  -74.0525 |             3193 | Lincoln Park       |                40.7246 |                -74.0784 |    29216 | Subscriber |         1993 |        1 |
|            921 | 2019-01-27 14:49:20.6290 | 2019-01-27 15:04:42.0540 |               3207 | Oakland Ave          |                  40.7376 |                  -74.0525 |             3275 | Columbus Drive     |                40.7184 |                -74.0389 |    29572 | Subscriber |         1988 |        1 |
|            207 | 2019-01-27 15:38:38.7620 | 2019-01-27 15:42:06.1550 |               3207 | Oakland Ave          |                  40.7376 |                  -74.0525 |             3206 | Hilltop            |                40.7312 |                -74.0576 |    26239 | Subscriber |         1993 |        2 |
|            610 | 2019-01-27 17:53:48.5590 | 2019-01-27 18:03:58.5750 |               3207 | Oakland Ave          |                  40.7376 |                  -74.0525 |             3201 | Dey St             |                40.7377 |                -74.0669 |    26431 | Subscriber |         1989 |        2 |


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 |
|---------------:|:-------------------------|:-------------------------|-------------------:|:---------------------|-------------------------:|--------------------------:|-----------------:|:------------------------|-----------------------:|------------------------:|---------:|:-----------|-------------:|---------:|
|            201 | 2019-01-01 03:09:09.7110 | 2019-01-01 03:12:30.8790 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3214 | Essex Light Rail        |                40.7128 |                -74.0365 |    29612 | Subscriber |         1993 |        1 |
|            505 | 2019-01-01 05:18:00.1060 | 2019-01-01 05:26:25.9050 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3638 | Washington St           |                40.7243 |                -74.0355 |    29213 | Subscriber |         1972 |        2 |
|            756 | 2019-01-01 10:36:33.3400 | 2019-01-01 10:49:10.2600 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3192 | Liberty Light Rail      |                40.7112 |                -74.0557 |    26164 | Subscriber |         1985 |        1 |
|           1575 | 2019-01-01 12:43:38.6430 | 2019-01-01 13:09:54.5280 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3638 | Washington St           |                40.7243 |                -74.0355 |    29672 | Customer   |         1969 |        0 |
|           1566 | 2019-01-01 12:43:39.6010 | 2019-01-01 13:09:46.5100 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3638 | Washington St           |                40.7243 |                -74.0355 |    29522 | Customer   |         1969 |        0 |
|            737 | 2019-01-01 12:56:53.2040 | 2019-01-01 13:09:11.0400 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3205 | JC Medical Center       |                40.7165 |                -74.0496 |    29447 | Subscriber |         1993 |        1 |
|            917 | 2019-01-01 13:03:44.7760 | 2019-01-01 13:19:02.7690 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3277 | Communipaw & Berry Lane |                40.7144 |                -74.0666 |    29299 | Subscriber |         1986 |        1 |
|           3248 | 2019-01-01 13:12:03.1280 | 2019-01-01 14:06:12.0400 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3196 | Riverview Park          |                40.7443 |                -74.044  |    29495 | Subscriber |         1992 |        1 |
|           3168 | 2019-01-01 13:13:12.0450 | 2019-01-01 14:06:00.4110 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3196 | Riverview Park          |                40.7443 |                -74.044  |    26312 | Customer   |         1969 |        0 |
|            353 | 2019-01-01 17:07:44.6670 | 2019-01-01 17:13:38.2640 |               3183 | Exchange Place       |                  40.7162 |                  -74.0335 |             3202 | Newport PATH            |                40.7272 |                -74.0338 |    26212 | Subscriber |         1994 |        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