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   |              2 |
| SR Watson  |              2 |
| KL Rahul   |              2 |
| RR Pant    |              1 |
| AM Rahane  |              1 |
| P Shaw     |              1 |
| KD Karthik |              1 |
| SV Samson  |              1 |
| J Bairstow |              1 |
| DA Warner  |              1 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| batsman        |   total_runs |
|:---------------|-------------:|
| AD Russell     |           82 |
| RR Pant        |           65 |
| CH Gayle       |           61 |
| KL Rahul       |           57 |
| AB de Villiers |           56 |
| SR Watson      |           56 |
| MS Dhoni       |           51 |
| AT Rayudu      |           41 |
| HH Pandya      |           41 |
| CA Lynn        |           40 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| batsman       |   batsman_runs |
|:--------------|---------------:|
| KL Rahul      |             17 |
| RR Pant       |             16 |
| S Dhawan      |             15 |
| KS Williamson |             15 |
| AS Yadav      |             15 |
| SS Iyer       |             14 |
| V Kohli       |             14 |
| CA Lynn       |             14 |
| MS Dhoni      |             13 |
| SK Raina      |             13 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
| batsman      |   batsman_runs |
|:-------------|---------------:|
| S Singh      |              0 |
| S Sharma     |              0 |
| S Rutherford |              0 |
| S Nadeem     |              0 |
| S Mavi       |              0 |
| S Lamichhane |              0 |
| S Kaul       |              0 |
| S Gopal      |              0 |
| Rashid Khan  |              0 |
| RD Chahar    |              0 |


Table #5
Filename: source_4.csv
Sample Rows in Markdown:
| batsman        |   no of balls |   batsman_runs |   strike |
|:---------------|--------------:|---------------:|---------:|
| A Dananjaya    |             5 |              4 |  80      |
| A Hales        |           119 |            152 | 127.731  |
| A Joseph       |            13 |             15 | 115.385  |
| A Mishra       |            28 |             28 | 100      |
| A Turner       |            11 |              4 |  36.3636 |
| AB de Villiers |           575 |            942 | 163.826  |
| AD Nath        |            71 |             71 | 100      |
| AD Russell     |           453 |            871 | 192.274  |
| AJ Finch       |           102 |            140 | 137.255  |
| AJ Tye         |            42 |             41 |  97.619  |


Target Schema:
| batsman        |   batsman_runs_x |   batsman_runs_y |   no of balls |   batsman_runs_x_4 |   strike |   batsman_runs_y_6 |   total_runs |
|:---------------|-----------------:|-----------------:|--------------:|-------------------:|---------:|-------------------:|-------------:|
| KL Rahul       |               13 |                2 |           873 |               1288 |  147.537 |                 17 |           57 |
| AB de Villiers |               11 |                0 |           575 |                942 |  163.826 |                 12 |           56 |
| RR Pant        |                9 |                1 |           723 |               1228 |  169.848 |                 16 |           65 |
| S Dhawan       |                9 |                0 |           771 |               1071 |  138.911 |                 15 |           25 |
| DA Warner      |                9 |                1 |           496 |                727 |  146.573 |                 10 |           22 |
| CH Gayle       |                8 |                2 |           599 |                909 |  151.753 |                 11 |           61 |
| JC Buttler     |                8 |                0 |           579 |                903 |  155.959 |                 11 |           36 |
| KS Williamson  |                8 |                0 |           656 |                908 |  138.415 |                 15 |           33 |
| V Kohli        |                8 |                1 |           717 |               1011 |  141.004 |                 14 |           31 |
| SR Watson      |                7 |                2 |           690 |                986 |  142.899 |                 12 |           56 |

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