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   | 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 |


Table #2
Filename: source_1.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   | Ярославль       |


Target Schema:
| geo             |   user_id |   time |   bet |   win |   email |
|:----------------|----------:|-------:|------:|------:|--------:|
| Арзангелтск     |        46 |     46 |     6 |     0 |      46 |
| Воронеж         |        39 |     39 |    11 |     3 |      39 |
| Екатеринбург    |        19 |     19 |     0 |     0 |      17 |
| Ижевск          |        34 |     34 |     9 |     3 |      34 |
| Казань          |        41 |     41 |     6 |     2 |      41 |
| Краснодар       |        41 |     41 |     4 |     0 |      41 |
| Красноярск      |        33 |     33 |     8 |     1 |      33 |
| Москва          |        33 |     33 |    14 |     3 |      33 |
| Пермь           |        28 |     28 |     4 |     1 |      28 |
| Санкт-Петербург |        60 |     60 |     9 |     2 |      60 |

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