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:
|   last_pymnt_d |
|---------------:|
|            386 |
|            383 |
|            121 |
|             92 |
|             92 |
|             68 |
|             66 |
|             66 |
|             64 |
|             61 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            412 |
|            401 |
|            101 |
|             79 |
|             76 |
|             69 |
|             63 |
|             62 |
|             61 |
|             60 |


Table #3
Filename: source_10.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            258 |
|            241 |
|            215 |
|            205 |
|            201 |
|            160 |
|             87 |
|             86 |
|             79 |
|             64 |


Table #4
Filename: source_11.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            172 |
|            157 |
|            151 |
|            147 |
|            144 |
|            142 |
|            127 |
|            115 |
|            112 |
|            103 |


Table #5
Filename: source_12.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|             27 |
|             27 |
|             26 |
|             25 |
|             25 |
|             24 |
|             23 |
|             22 |
|             20 |
|             20 |


Table #6
Filename: source_13.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            426 |
|            186 |
|            180 |
|            149 |
|             76 |
|             65 |
|             63 |
|             62 |
|             61 |
|             60 |


Table #7
Filename: source_14.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            267 |
|            264 |
|            191 |
|             93 |
|             92 |
|             82 |
|             82 |
|             71 |
|             69 |
|             67 |


Table #8
Filename: source_2.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            288 |
|            258 |
|            254 |
|            109 |
|             93 |
|             81 |
|             80 |
|             75 |
|             73 |
|             70 |


Table #9
Filename: source_3.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            361 |
|            248 |
|            145 |
|            104 |
|            101 |
|             64 |
|             63 |
|             62 |
|             60 |
|             60 |


Table #10
Filename: source_4.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            552 |
|            164 |
|            163 |
|            118 |
|             79 |
|             69 |
|             65 |
|             62 |
|             61 |
|             59 |


Table #11
Filename: source_5.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            381 |
|            309 |
|            118 |
|            117 |
|             87 |
|             85 |
|             71 |
|             67 |
|             66 |
|             65 |


Table #12
Filename: source_6.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            366 |
|            320 |
|            293 |
|            291 |
|             79 |
|             74 |
|             71 |
|             71 |
|             71 |
|             65 |


Table #13
Filename: source_7.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            421 |
|            342 |
|             95 |
|             92 |
|             78 |
|             67 |
|             67 |
|             66 |
|             66 |
|             63 |


Table #14
Filename: source_8.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|            660 |
|            182 |
|            173 |
|             69 |
|             67 |
|             60 |
|             60 |
|             60 |
|             58 |
|             57 |


Table #15
Filename: source_9.csv
Sample Rows in Markdown:
|   last_pymnt_d |
|---------------:|
|             48 |
|             46 |
|             29 |
|             28 |
|             25 |
|             23 |
|             23 |
|             20 |
|             17 |
|             16 |


Target Schema:
|   last_pymnt_d |
|---------------:|
|            660 |
|            182 |
|            173 |
|             69 |
|             67 |
|             60 |
|             60 |
|             60 |
|             58 |
|             57 |

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_10.csv
source_11.csv
source_12.csv
source_13.csv
source_14.csv
source_2.csv
source_3.csv
source_4.csv
source_5.csv
source_6.csv
source_7.csv
source_8.csv
source_9.csv
test: test_0.csv
test_1.csv
test_10.csv
test_11.csv
test_12.csv
test_13.csv
test_14.csv
test_2.csv
test_3.csv
test_4.csv
test_5.csv
test_6.csv
test_7.csv
test_8.csv
test_9.csv