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:
| batsman        |   batsman_runs |
|:---------------|---------------:|
| DA Warner      |             48 |
| V Kohli        |             42 |
| SK Raina       |             38 |
| CH Gayle       |             35 |
| G Gambhir      |             34 |
| AB de Villiers |             34 |
| RG Sharma      |             32 |
| S Dhawan       |             32 |
| AM Rahane      |             29 |
| MS Dhoni       |             23 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| batsman    |   total_runs |
|:-----------|-------------:|
| S Dhawan   |          529 |
| G Gambhir  |          499 |
| SK Raina   |          492 |
| V Kohli    |          486 |
| DA Warner  |          462 |
| RV Uthappa |          443 |
| RG Sharma  |          431 |
| AM Rahane  |          410 |
| CH Gayle   |          383 |
| PA Patel   |          369 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| batsman        |   total_runs |
|:---------------|-------------:|
| CH Gayle       |          322 |
| AB de Villiers |          211 |
| MS Dhoni       |          207 |
| SK Raina       |          194 |
| RG Sharma      |          193 |
| V Kohli        |          190 |
| DA Warner      |          179 |
| SR Watson      |          178 |
| KA Pollard     |          174 |
| YK Pathan      |          161 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
| batsman        |   batsman_runs |
|:---------------|---------------:|
| CH Gayle       |              7 |
| V Kohli        |              5 |
| SR Watson      |              4 |
| DA Warner      |              4 |
| AB de Villiers |              3 |
| AC Gilchrist   |              2 |
| HM Amla        |              2 |
| V Sehwag       |              2 |
| AM Rahane      |              2 |
| KL Rahul       |              2 |


Table #5
Filename: source_4.csv
Sample Rows in Markdown:
| batsman         |   batsman_runs |
|:----------------|---------------:|
| AA Bilakhia     |        9.85714 |
| AG Paunikar     |        9.8     |
| DJ Thornely     |        9.75    |
| Umar Gul        |        9.75    |
| Harbhajan Singh |        9.69767 |
| KK Cooper       |        9.66667 |
| JDP Oram        |        9.63636 |
| R Dhawan        |        9.5625  |
| A Mukund        |        9.5     |
| P Sahu          |        9.5     |


Target Schema:
| batsman     |   batsman_runs_x |   total_runs_x |   total_runs_y |   batsman_runs_y |   batsman_runs |
|:------------|-----------------:|---------------:|---------------:|-----------------:|---------------:|
| J Bairstow  |          46.8    |             50 |             18 |                4 |              1 |
| DA Warner   |          37.627  |            462 |            179 |               48 |              4 |
| LMP Simmons |          37.2069 |            110 |             44 |               12 |              1 |
| CH Gayle    |          36.7742 |            383 |            322 |               35 |              7 |
| SE Marsh    |          36.0725 |            274 |             77 |               21 |              1 |
| HM Amla     |          36.0625 |             60 |             21 |                5 |              2 |
| KL Rahul    |          34.7069 |            177 |             81 |               17 |              2 |
| ML Hayden   |          34.5938 |            124 |             44 |                8 |              0 |
| MEK Hussey  |          34.0862 |            200 |             52 |               16 |              1 |
| R Parag     |          33.8    |             18 |              5 |                1 |              0 |

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
source_2.csv
source_3.csv
source_4.csv
test: test_0.csv
test_1.csv
test_2.csv
test_3.csv
test_4.csv