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 |
|:---------------|---------------:|
| 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 #2
Filename: source_1.csv
Sample Rows in Markdown:
| batsman      |   total_runs |
|:-------------|-------------:|
| DJ Thornely  |            2 |
| BB Samantray |            2 |
| DH Yagnik    |            2 |
| AUK Pathan   |            2 |
| A Flintoff   |            2 |
| J Suchith    |            2 |
| AD Nath      |            2 |
| CR Woakes    |            2 |
| P Sahu       |            1 |
| AP Dole      |            1 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| batsman        |   no of balls |   batsman_runs |   strike |
|:---------------|--------------:|---------------:|---------:|
| A Ashish Reddy |           196 |            280 | 142.857  |
| A Chandila     |             7 |              4 |  57.1429 |
| A Chopra       |            75 |             53 |  70.6667 |
| A Choudhary    |            20 |             25 | 125      |
| A Dananjaya    |             5 |              4 |  80      |
| A Flintoff     |            57 |             62 | 108.772  |
| A Hales        |           119 |            152 | 127.731  |
| A Joseph       |            13 |             15 | 115.385  |
| A Kumble       |            49 |             35 |  71.4286 |
| A Mishra       |           410 |            368 |  89.7561 |


Table #4
Filename: source_3.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 #5
Filename: source_4.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 |


Target Schema:
| batsman        |   total_runs_x |   batsman_runs_x |   batsman_runs_y |   no of balls |   batsman_runs |   strike |   total_runs_y |
|:---------------|---------------:|-----------------:|-----------------:|--------------:|---------------:|---------:|---------------:|
| CH Gayle       |            322 |               35 |                7 |          3131 |           4560 |  145.64  |            383 |
| AB de Villiers |            211 |               34 |                3 |          2977 |           4428 |  148.74  |            361 |
| MS Dhoni       |            207 |               23 |                0 |          3318 |           4477 |  134.931 |            303 |
| SK Raina       |            194 |               38 |                1 |          4044 |           5415 |  133.902 |            492 |
| RG Sharma      |            193 |               32 |                1 |          3816 |           4914 |  128.774 |            431 |
| V Kohli        |            190 |               42 |                5 |          4211 |           5434 |  129.043 |            486 |
| DA Warner      |            179 |               48 |                4 |          3398 |           4741 |  139.523 |            462 |
| SR Watson      |            178 |               22 |                4 |          2639 |           3614 |  136.946 |            345 |
| KA Pollard     |            174 |               13 |                0 |          1964 |           2784 |  141.752 |            184 |
| YK Pathan      |            161 |               15 |                1 |          2334 |           3241 |  138.86  |            265 |

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