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   | email                | geo             |
|:----------|:---------------------|:----------------|
| user_943  | Accumanst@gmail.com  | Ижевск          |
| user_908  | Advismowr@mail.ru    | Ижевск          |
| user_962  | Anachso@ukr.net      | Краснодар       |
| user_973  | Antecia@inbox.ru     | Пермь           |
| user_902  | Balliaryva@ukr.net   |                 |
| user_976  | Bigbytech@rambler.ru | Краснодар       |
| user_955  | Billionon@rambler.ru | Санкт-Петербург |
| user_992  | BloggerJan@yahoo     | Санкт-Петербург |
| user_978  | Blueterva@ya.ru      | Ижевск          |
| user_939  | Bootrasync@ukr.net   | Ярославль       |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| user_id   | time                 | bet   | win    |
|:----------|:---------------------|:------|:-------|
| user_912  | [2019-02-24 11:42:42 |       |        |
| user_966  | [2019-02-24 12:09:42 | 200.0 |        |
| user_933  | [2019-02-24 14:14:26 |       |        |
| user_914  | [2019-02-24 14:30:43 |       |        |
| user_932  | [2019-02-24 22:40:06 |       |        |
| user_946  | [2019-02-24 7:31:17  |       |        |
| user_922  | [2019-02-24 8:29:11  | 300.0 |        |
| user_958  | [2019-02-24 9:55:42  | 400.0 |        |
| user_925  | [2019-02-25 1:46:02  |       |        |
| user_918  | [2019-02-25 1:50:30  | 400.0 | 4829.0 |


Target Schema:
| user_id   |   time |   bet |   win |   email |   geo |
|:----------|-------:|------:|------:|--------:|------:|
| user_1000 |      5 |     1 |     0 |       5 |     5 |
| user_900  |      8 |     2 |     1 |       8 |     8 |
| user_901  |      5 |     0 |     0 |       5 |     5 |
| user_902  |      3 |     0 |     0 |       3 |     0 |
| user_903  |      7 |     3 |     1 |       7 |     7 |
| user_904  |      4 |     0 |     0 |       4 |     4 |
| user_905  |      7 |     4 |     1 |       7 |     7 |
| user_906  |      7 |     0 |     0 |       7 |     7 |
| user_907  |      4 |     1 |     1 |       4 |     4 |
| user_908  |      6 |     1 |     0 |       6 |     6 |

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