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:
| InvoiceNo   | StockCode   | Description                        |   Quantity | InvoiceDate         |   UnitPrice |   CustomerID | Country        |
|:------------|:------------|:-----------------------------------|-----------:|:--------------------|------------:|-------------:|:---------------|
| 575938      | 23357       | HOT WATER BOTTLE SEX BOMB          |          1 | 2011-11-13 11:30:00 |        4.95 |        17790 | United Kingdom |
| C569636     | 22960       | JAM MAKING SET WITH JARS           |         -2 | 2011-10-05 12:14:00 |        4.25 |        12841 | United Kingdom |
| 546774      | 21929       | JUMBO BAG PINK VINTAGE PAISLEY     |          3 | 2011-03-16 15:45:00 |        1.95 |        14505 | United Kingdom |
| 550797      | 21977       | PACK OF 60 PINK PAISLEY CAKE CASES |         12 | 2011-04-20 14:40:00 |        0.42 |        12901 | United Kingdom |
| 572866      | 20719       | WOODLAND CHARLOTTE BAG             |          6 | 2011-10-26 13:07:00 |        0.85 |        15005 | United Kingdom |
| 544455      | 47590B      | PINK HAPPY BIRTHDAY BUNTING        |          2 | 2011-02-20 13:18:00 |        5.45 |        13097 | United Kingdom |
| C542787     | 21319       | GLASS CHALICE GREEN  SMALL         |         -1 | 2011-02-01 10:22:00 |        1.65 |        15864 | United Kingdom |
| 563435      | 21770       | OPEN CLOSED METAL SIGN             |          8 | 2011-08-16 12:29:00 |        4.95 |        16131 | United Kingdom |
| 570115      | 47591D      | PINK FAIRY CAKE CHILDRENS APRON    |         50 | 2011-10-07 12:37:00 |        1.65 |        13798 | United Kingdom |
| 559679      | 23228       | FILIGREE HEART BIRD WHITE          |         24 | 2011-07-11 14:46:00 |        1.25 |        15265 | United Kingdom |


Target Schema:
|   CustomerID | InvoiceDate_x       |   InvoiceNo_x |   StockCode_x |   Description_x |   Quantity_x |   InvoiceDate_y |   UnitPrice_x |   Country_x |   InvoiceNo_y |   StockCode_y |   Description_y |   Quantity_y |   InvoiceDate |   UnitPrice_y |   Country_y |
|-------------:|:--------------------|--------------:|--------------:|----------------:|-------------:|----------------:|--------------:|------------:|--------------:|--------------:|----------------:|-------------:|--------------:|--------------:|------------:|
|        12747 | 2011-03-01 14:53:00 |             4 |             4 |               4 |            3 |               4 |             4 |           1 |             4 |             4 |               4 |            4 |             4 |             4 |           4 |
|        12748 | 2011-02-17 14:42:00 |            50 |            74 |              74 |           16 |              51 |            27 |           1 |            74 |            74 |              74 |           74 |            74 |            74 |          74 |
|        12749 | 2011-05-23 17:08:00 |             3 |             4 |               4 |            4 |               3 |             3 |           1 |             4 |             4 |               4 |            4 |             4 |             4 |           4 |
|        12824 | 2011-10-11 12:49:00 |             1 |             1 |               1 |            1 |               1 |             1 |           1 |             1 |             1 |               1 |            1 |             1 |             1 |           1 |
|        12827 | 2011-10-26 15:44:00 |             1 |             1 |               1 |            1 |               1 |             1 |           1 |             1 |             1 |               1 |            1 |             1 |             1 |           1 |
|        12830 | 2011-11-02 11:54:00 |             1 |             1 |               1 |            1 |               1 |             1 |           1 |             1 |             1 |               1 |            1 |             1 |             1 |           1 |
|        12834 | 2011-03-02 09:49:00 |             1 |             1 |               1 |            1 |               1 |             1 |           1 |             1 |             1 |               1 |            1 |             1 |             1 |           1 |
|        12837 | 2011-06-19 16:07:00 |             1 |             1 |               1 |            1 |               1 |             1 |           1 |             1 |             1 |               1 |            1 |             1 |             1 |           1 |
|        12839 | 2011-05-25 14:18:00 |             3 |             3 |               3 |            3 |               3 |             3 |           1 |             3 |             3 |               3 |            3 |             3 |             3 |           3 |
|        12840 | 2011-04-27 12:21:00 |             1 |             1 |               1 |            1 |               1 |             1 |           1 |             1 |             1 |               1 |            1 |             1 |             1 |           1 |

Return only the final code in markdown codeblock format, without any additional text or explanation. 



target: target.csv
train: source_0.csv
test: test_0.csv