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    |   total_runs |
|:-----------|-------------:|
| DA Warner  |          150 |
| G Gambhir  |          118 |
| V Kohli    |          107 |
| S Dhawan   |          104 |
| AM Rahane  |           89 |
| RV Uthappa |           84 |
| RG Sharma  |           82 |
| SK Raina   |           80 |
| KK Nair    |           79 |
| PA Patel   |           74 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| batsman        |   batsman_runs |
|:---------------|---------------:|
| V Kohli        |             15 |
| DA Warner      |             14 |
| G Gambhir      |              9 |
| AM Rahane      |              8 |
| RG Sharma      |              8 |
| AB de Villiers |              8 |
| RV Uthappa     |              8 |
| S Dhawan       |              7 |
| SK Raina       |              6 |
| M Vijay        |              5 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| batsman        |   total_runs |
|:---------------|-------------:|
| DA Warner      |           56 |
| AB de Villiers |           53 |
| V Kohli        |           48 |
| KA Pollard     |           39 |
| CH Gayle       |           35 |
| GJ Maxwell     |           34 |
| BB McCullum    |           34 |
| RR Pant        |           30 |
| AJ Finch       |           30 |
| MS Dhoni       |           30 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
| batsman     |   batsman_runs |
|:------------|---------------:|
| DA Warner   |             21 |
| V Kohli     |             16 |
| AM Rahane   |             14 |
| S Dhawan    |             14 |
| G Gambhir   |             14 |
| SPD Smith   |             12 |
| KD Karthik  |             12 |
| BB McCullum |             12 |
| RV Uthappa  |             11 |
| SK Raina    |             11 |


Table #5
Filename: source_4.csv
Sample Rows in Markdown:
| batsman       |   batsman_runs |
|:--------------|---------------:|
| HH Pandya     |        11.76   |
| STR Binny     |        11.75   |
| Bipul Sharma  |        11.7143 |
| NS Naik       |        11.5    |
| SR Watson     |        11.3636 |
| DJ Hooda      |        10.5714 |
| Kuldeep Yadav |        10      |
| C Munro       |        10      |
| Parvez Rasool |        10      |
| PJ Cummins    |         9.625  |


Table #6
Filename: source_5.csv
Sample Rows in Markdown:
| batsman        |   no of balls |   batsman_runs |   strike |
|:---------------|--------------:|---------------:|---------:|
| A Ashish Reddy |            30 |             47 | 156.667  |
| A Choudhary    |            20 |             25 | 125      |
| A Mishra       |            70 |             53 |  75.7143 |
| A Nehra        |             1 |              1 | 100      |
| A Zampa        |             8 |              5 |  62.5    |
| AB Dinda       |             8 |              7 |  87.5    |
| AB de Villiers |           586 |            903 | 154.096  |
| AD Mathews     |            28 |             32 | 114.286  |
| AD Nath        |            28 |             20 |  71.4286 |
| AD Russell     |           125 |            188 | 150.4    |


Table #7
Filename: source_6.csv
Sample Rows in Markdown:
| batsman        |   batsman_runs |
|:---------------|---------------:|
| V Kohli        |              4 |
| HM Amla        |              2 |
| SV Samson      |              1 |
| Q de Kock      |              1 |
| BA Stokes      |              1 |
| SPD Smith      |              1 |
| AB de Villiers |              1 |
| DA Warner      |              1 |
| PA Patel       |              0 |
| PJ Cummins     |              0 |


Target Schema:
| batsman        |   batsman_runs_x |   total_runs_x |   total_runs_y |   batsman_runs_y |   batsman_runs_x_5 |   no of balls |   batsman_runs_y_7 |   strike |   batsman_runs |
|:---------------|-----------------:|---------------:|---------------:|-----------------:|-------------------:|--------------:|-------------------:|---------:|---------------:|
| V Kohli        |          49.2692 |            107 |             48 |               15 |                  4 |           912 |               1281 |  140.461 |             16 |
| DA Warner      |          48.0323 |            150 |             56 |               14 |                  1 |          1041 |               1489 |  143.036 |             21 |
| AB de Villiers |          36.12   |             71 |             53 |                8 |                  1 |           586 |                903 |  154.096 |             10 |
| HM Amla        |          36.0625 |             60 |             21 |                5 |                  2 |           418 |                577 |  138.038 |              6 |
| CA Lynn        |          35.5556 |             25 |             20 |                2 |                  0 |           198 |                320 |  161.616 |              4 |
| Q de Kock      |          34.2308 |             53 |             13 |                4 |                  1 |           340 |                445 |  130.882 |              7 |
| SPD Smith      |          33.7273 |             66 |             20 |                4 |                  1 |           584 |                742 |  127.055 |             12 |
| KL Rahul       |          33.0833 |             37 |             16 |                4 |                  0 |           277 |                397 |  143.321 |              7 |
| M Vijay        |          32.3571 |             52 |             10 |                5 |                  0 |           373 |                453 |  121.448 |              6 |
| G Gambhir      |          32.2258 |            118 |             13 |                9 |                  0 |           829 |                999 |  120.507 |             14 |

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
source_5.csv
source_6.csv
test: test_0.csv
test_1.csv
test_2.csv
test_3.csv
test_4.csv
test_5.csv
test_6.csv