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:
|   Purchase ID | SN            |   Age | Gender   |   Item ID | Item Name                   |   Price |
|--------------:|:--------------|------:|:---------|----------:|:----------------------------|--------:|
|           390 | Asur53        |    26 | Male     |        75 | Brutality Ivory Warmace     |    2.42 |
|           391 | Alarap40      |    18 | Male     |        20 | Netherbane                  |    3.27 |
|           392 | Sida61        |    20 | Female   |       181 | Reaper's Toll               |    1.66 |
|           393 | Hiarideu73    |    20 | Male     |        54 | Eternal Cleaver             |    2.5  |
|           394 | Lassassasda30 |    12 | Male     |        60 | Wolf                        |    3.54 |
|           395 | Ennoncil86    |    17 | Male     |       152 | Darkheart                   |    1.74 |
|           396 | Siralsudeu54  |    20 | Male     |       131 | Fury                        |    1.44 |
|           397 | Eusri26       |    25 | Male     |       100 | Blindscythe                 |    3.27 |
|           398 | Ardcil81      |    34 | Male     |        96 | Blood-Forged Skeletal Spine |    3.09 |
|           399 | Marilsasya33  |    19 | Male     |       143 | Frenzied Scimitar           |    1.56 |


Target Schema:
| Item Name                            |   Purchase ID |   SN |   Age |   Gender |   Item ID |   Price_x |   Purchase ID_x |   Age_x |   Item ID_x |   Price_y |   Item ID_y |   Purchase ID_y |   Age_y |
|:-------------------------------------|--------------:|-----:|------:|---------:|----------:|----------:|----------------:|--------:|------------:|----------:|------------:|----------------:|--------:|
| Abyssal Shard                        |             3 |    3 |     3 |        3 |         3 |         3 |             227 |      65 |         486 |      8.01 |         162 |             227 |      65 |
| Aetherius, Boon of the Blessed       |             3 |    3 |     3 |        3 |         3 |         3 |             831 |      90 |         411 |     10.17 |         137 |             831 |      90 |
| Agatha                               |             2 |    2 |     2 |        2 |         2 |         2 |             341 |      42 |         240 |      6.16 |         120 |             341 |      42 |
| Alpha, Oath of Zeal                  |             1 |    1 |     1 |        1 |         1 |         1 |             352 |      22 |          79 |      4.05 |          79 |             352 |      22 |
| Amnesia                              |             2 |    2 |     2 |        2 |         2 |         2 |             194 |      39 |          44 |      4.36 |          22 |             194 |      39 |
| Amnesia                              |             2 |    2 |     2 |        2 |         2 |         2 |             194 |      39 |          44 |      4.36 |         169 |             303 |      52 |
| Arcane Gem                           |             1 |    1 |     1 |        1 |         1 |         1 |              55 |      25 |          84 |      3.79 |          84 |              55 |      25 |
| Avenger                              |             4 |    4 |     4 |        4 |         4 |         4 |             574 |     118 |         408 |     13.76 |         102 |             574 |     118 |
| Azurewrath                           |             2 |    2 |     2 |        2 |         2 |         2 |             116 |      35 |         320 |      8.8  |         160 |             116 |      35 |
| Betrayal, Whisper of Grieving Widows |             4 |    4 |     4 |        4 |         4 |         4 |             880 |      88 |         156 |     15.76 |          39 |             880 |      88 |

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