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        |
|------------:|:------------|:------------------------------------|-----------:|:--------------------|------------:|-------------:|:---------------|
|      562393 | 23274       | STAR T-LIGHT HOLDER WILLIE WINKIE   |         24 | 2011-08-04 16:17:00 |        1.65 |        18172 | United Kingdom |
|      574250 | 84596B      | SMALL DOLLY MIX DESIGN ORANGE BOWL  |          2 | 2011-11-03 13:09:00 |        0.42 |        17634 | United Kingdom |
|      568049 | 21669       | BLUE STRIPE CERAMIC DRAWER KNOB     |          2 | 2011-09-23 12:38:00 |        1.45 |        17841 | United Kingdom |
|      564722 | 84832       | ZINC WILLIE WINKIE  CANDLE STICK    |          2 | 2011-08-28 12:06:00 |        0.85 |        16456 | United Kingdom |
|      541490 | 18097C      | WHITE TALL PORCELAIN T-LIGHT HOLDER |         48 | 2011-01-18 13:40:00 |        1.95 |        13984 | United Kingdom |
|      546762 | 21244       | BLUE POLKADOT PLATE                 |          2 | 2011-03-16 14:12:00 |        1.69 |        17961 | United Kingdom |
|      559128 | 22352       | LUNCH BOX WITH CUTLERY RETROSPOT    |          1 | 2011-07-06 12:39:00 |        2.55 |        17238 | United Kingdom |
|      545462 | 22064       | PINK DOUGHNUT TRINKET POT           |         12 | 2011-03-03 08:24:00 |        1.65 |        17567 | United Kingdom |
|      575215 | 23112       | PARISIENNE CURIO CABINET            |          2 | 2011-11-09 11:04:00 |        7.5  |        18109 | United Kingdom |
|      543096 | 22077       | 6 RIBBONS RUSTIC CHARM              |          1 | 2011-02-03 11:39:00 |        1.65 |        14044 | United Kingdom |


Target Schema:
|   CustomerID | InvoiceDate_x       |   InvoiceNo_x |   StockCode_x |   Description_x |   Quantity_x |   InvoiceDate_y |   UnitPrice_x |   Country_x |   returned_x |   InvoiceNo_y |   StockCode_y |   Description_y |   Quantity_y |   InvoiceDate |   UnitPrice_y |   Country_y |   returned_y |
|-------------:|:--------------------|--------------:|--------------:|----------------:|-------------:|----------------:|--------------:|------------:|-------------:|--------------:|--------------:|----------------:|-------------:|--------------:|--------------:|------------:|-------------:|
|        12747 | 2011-08-22 10:38:00 |             2 |             2 |               2 |            1 |               2 |             2 |           1 |            1 |             2 |             2 |               2 |            2 |             2 |             2 |           2 |            2 |
|        12748 | 2011-02-17 14:42:00 |            35 |            42 |              42 |           13 |              35 |            21 |           1 |            2 |            42 |            42 |              42 |           42 |            42 |            42 |          42 |           42 |
|        12749 | 2011-12-06 09:56:00 |             1 |             2 |               2 |            2 |               1 |             2 |           1 |            1 |             2 |             2 |               2 |            2 |             2 |             2 |           2 |            2 |
|        12824 | 2011-10-11 12:49:00 |             1 |             1 |               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 |           1 |            1 |
|        12837 | 2011-06-19 16:07:00 |             1 |             1 |               1 |            1 |               1 |             1 |           1 |            1 |             1 |             1 |               1 |            1 |             1 |             1 |           1 |            1 |
|        12839 | 2011-11-15 09:26:00 |             1 |             1 |               1 |            1 |               1 |             1 |           1 |            1 |             1 |             1 |               1 |            1 |             1 |             1 |           1 |            1 |
|        12840 | 2011-04-27 12:21:00 |             1 |             1 |               1 |            1 |               1 |             1 |           1 |            1 |             1 |             1 |               1 |            1 |             1 |             1 |           1 |            1 |
|        12841 | 2011-03-27 12:54:00 |             1 |             1 |               1 |            1 |               1 |             1 |           1 |            1 |             1 |             1 |               1 |            1 |             1 |             1 |           1 |            1 |
|        12843 | 2011-06-06 14:31:00 |             1 |             1 |               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