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:
|   SEQN |   Albumin(ug/mL) |   creatinine(mg/dL) |
|-------:|-----------------:|--------------------:|
|  83732 |              2.5 |                  41 |
|  83733 |             23.2 |                 181 |
|  83734 |            105   |                  70 |
|  83735 |              5.8 |                 102 |
|  83736 |             47.6 |                 315 |
|  83737 |             10.4 |                  64 |
|  83738 |              7.4 |                 100 |
|  83739 |              2   |                  25 |
|  83741 |              3.9 |                  75 |
|  83742 |              5.7 |                 107 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   SEQN |   glycohemoglobin |
|-------:|------------------:|
|  83732 |               7   |
|  83733 |               5.5 |
|  83734 |               5.8 |
|  83735 |               5.6 |
|  83736 |               5.6 |
|  83737 |               5.9 |
|  83741 |               5.6 |
|  83742 |               5.6 |
|  83743 |               5.3 |
|  83744 |               7.6 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|   SEQN |   total_cholesterol(mg/dL) |
|-------:|---------------------------:|
|  83732 |                        173 |
|  83733 |                        265 |
|  83734 |                        229 |
|  83735 |                        174 |
|  83736 |                        204 |
|  83737 |                        190 |
|  83738 |                        142 |
|  83741 |                        164 |
|  83742 |                        190 |
|  83743 |                        165 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
|   SEQN | 60_sec_pulse   | systolic   | diastolic   |
|-------:|:---------------|:-----------|:------------|
|  83732 | 76.0           | 128.0      | 70.0        |
|  83733 | 72.0           | 146.0      | 88.0        |
|  83734 | 56.0           | 138.0      | 46.0        |
|  83735 | 78.0           | 132.0      | 72.0        |
|  83736 | 76.0           | 100.0      | 70.0        |
|  83737 | 64.0           | 116.0      | 58.0        |
|  83738 | 78.0           | 102.0      | 36.0        |
|  83739 |                |            |             |
|  83740 |                |            |             |
|  83741 | 66.0           | 110.0      | 70.0        |


Table #5
Filename: source_4.csv
Sample Rows in Markdown:
|   SEQN |   weight_kg |   standing_height | waist_circumference   |   arm_circumference |
|-------:|------------:|------------------:|:----------------------|--------------------:|
|  88727 |        37.6 |             155.8 | 63.7                  |                20.6 |
|  88728 |        86.9 |             147.1 | 117.6                 |                34   |
|  88729 |        82.2 |             153.6 | 122.1                 |                31.8 |
|  88730 |         8.1 |              66.4 |                       |                15.5 |
|  88731 |        58.6 |             172.9 | 76.3                  |                26   |
|  88732 |        54.9 |             165.1 | 76.1                  |                25   |
|  88733 |        60.8 |             167.1 | 72.2                  |                25.4 |
|  88734 |        43.1 |             136.3 | 71.7                  |                25.6 |
|  88735 |        11.4 |              81.4 |                       |                15.4 |
|  88736 |        30.2 |             134.1 | 59.5                  |                19.2 |


Table #6
Filename: source_5.csv
Sample Rows in Markdown:
|   SEQN |   hepatitis_A |
|-------:|--------------:|
|  83732 |             0 |
|  83733 |             1 |
|  83734 |             1 |
|  83735 |             0 |
|  83736 |             0 |
|  83737 |             1 |
|  83738 |             1 |
|  83739 |             1 |
|  83741 |             1 |
|  83742 |             1 |


Table #7
Filename: source_6.csv
Sample Rows in Markdown:
|   SEQN |   Have little interest in doing things |   Feeling down, depressed, or hopeless |   Trouble sleeping or sleeping too much |   Feeling tired or having little energy |   Poor appetite or overeating |   Feeling bad about yourself |   Trouble concentrating on things |   Moving or speaking slowly or too fast |   Thought you would be better off dead |
|-------:|---------------------------------------:|---------------------------------------:|----------------------------------------:|----------------------------------------:|------------------------------:|-----------------------------:|----------------------------------:|----------------------------------------:|---------------------------------------:|
|  83732 |                                      0 |                                      0 |                                       0 |                                       1 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83733 |                                      1 |                                      0 |                                       0 |                                       0 |                             1 |                            0 |                                 0 |                                       0 |                                      0 |
|  83734 |                                      0 |                                      0 |                                       0 |                                       1 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83735 |                                      1 |                                      1 |                                       2 |                                       2 |                             1 |                            3 |                                 2 |                                       0 |                                      1 |
|  83736 |                                      1 |                                      1 |                                       1 |                                       1 |                             3 |                            0 |                                 1 |                                       0 |                                      0 |
|  83737 |                                      0 |                                      0 |                                       0 |                                       0 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83741 |                                      0 |                                      0 |                                       0 |                                       1 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83742 |                                      0 |                                      0 |                                       1 |                                       0 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83744 |                                      0 |                                      0 |                                       0 |                                       0 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83747 |                                      0 |                                      0 |                                       2 |                                       0 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |


Table #8
Filename: source_7.csv
Sample Rows in Markdown:
|   SEQN |   calcium(mg/dL) |   iron(ug/dL) |   potassium(mmol/L) |   sodium(mmol/L) |   phosphorus(mg/dL) |   total_protein(g/dL) |   triglycerides(mg/dL) |
|-------:|-----------------:|--------------:|--------------------:|-----------------:|--------------------:|----------------------:|-----------------------:|
|  83732 |              9.8 |            70 |                4.3  |              136 |                 4.7 |                   7.5 |                    158 |
|  83733 |              9.8 |           161 |                4.55 |              140 |                 4.4 |                   7.4 |                    170 |
|  83734 |              9.7 |            72 |                4.7  |              140 |                 3.6 |                   7.3 |                    299 |
|  83735 |              8.9 |            43 |                4.08 |              141 |                 3.8 |                   6.1 |                     93 |
|  83736 |              9.3 |            44 |                3.5  |              136 |                 3.2 |                   7.7 |                     52 |
|  83737 |              9.3 |            75 |                4.2  |              140 |                 3.7 |                   7.1 |                     52 |
|  83741 |              9.3 |            64 |                4.16 |              139 |                 5.3 |                   7.4 |                     77 |
|  83742 |             10.3 |            51 |                4.31 |              138 |                 3.1 |                   7.4 |                    295 |
|  83743 |              9.6 |           104 |                3.97 |              137 |                 4.3 |                   8.1 |                     73 |
|  83744 |              9.5 |           137 |                4.5  |              140 |                 4.1 |                   6.9 |                    121 |


Target Schema:
|   SEQN |   weight_kg |   standing_height |   waist_circumference |   arm_circumference |   60_sec_pulse |   systolic |   diastolic |   Albumin(ug/mL) |   creatinine(mg/dL) |   total_cholesterol(mg/dL) |   glycohemoglobin |   hepatitis_A |   calcium(mg/dL) |   iron(ug/dL) |   potassium(mmol/L) |   sodium(mmol/L) |   phosphorus(mg/dL) |   total_protein(g/dL) |   triglycerides(mg/dL) |   Have little interest in doing things |   Feeling down, depressed, or hopeless |   Trouble sleeping or sleeping too much |   Feeling tired or having little energy |   Poor appetite or overeating |   Feeling bad about yourself |   Trouble concentrating on things |   Moving or speaking slowly or too fast |   Thought you would be better off dead |
|-------:|------------:|------------------:|----------------------:|--------------------:|---------------:|-----------:|------------:|-----------------:|--------------------:|---------------------------:|------------------:|--------------:|-----------------:|--------------:|--------------------:|-----------------:|--------------------:|----------------------:|-----------------------:|---------------------------------------:|---------------------------------------:|----------------------------------------:|----------------------------------------:|------------------------------:|-----------------------------:|----------------------------------:|----------------------------------------:|---------------------------------------:|
|  83732 |        94.8 |             184.5 |                 101.1 |                35.9 |             76 |        128 |          70 |              2.5 |                  41 |                        173 |               7   |             0 |              9.8 |            70 |                4.3  |              136 |                 4.7 |                   7.5 |                    158 |                                      0 |                                      0 |                                       0 |                                       1 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83733 |        90.4 |             171.4 |                 107.9 |                33.2 |             72 |        146 |          88 |             23.2 |                 181 |                        265 |               5.5 |             1 |              9.8 |           161 |                4.55 |              140 |                 4.4 |                   7.4 |                    170 |                                      1 |                                      0 |                                       0 |                                       0 |                             1 |                            0 |                                 0 |                                       0 |                                      0 |
|  83734 |        83.4 |             170.1 |                 116.5 |                31   |             56 |        138 |          46 |            105   |                  70 |                        229 |               5.8 |             1 |              9.7 |            72 |                4.7  |              140 |                 3.6 |                   7.3 |                    299 |                                      0 |                                      0 |                                       0 |                                       1 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83735 |       109.8 |             160.9 |                 110.1 |                38.3 |             78 |        132 |          72 |              5.8 |                 102 |                        174 |               5.6 |             0 |              8.9 |            43 |                4.08 |              141 |                 3.8 |                   6.1 |                     93 |                                      1 |                                      1 |                                       2 |                                       2 |                             1 |                            3 |                                 2 |                                       0 |                                      1 |
|  83736 |        55.2 |             164.9 |                  80.4 |                27.2 |             76 |        100 |          70 |             47.6 |                 315 |                        204 |               5.6 |             0 |              9.3 |            44 |                3.5  |              136 |                 3.2 |                   7.7 |                     52 |                                      1 |                                      1 |                                       1 |                                       1 |                             3 |                            0 |                                 1 |                                       0 |                                      0 |
|  83737 |        64.4 |             150   |                  92.9 |                31.4 |             64 |        116 |          58 |             10.4 |                  64 |                        190 |               5.9 |             1 |              9.3 |            75 |                4.2  |              140 |                 3.7 |                   7.1 |                     52 |                                      0 |                                      0 |                                       0 |                                       0 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83741 |        76.6 |             165.4 |                  86.6 |                34   |             66 |        110 |          70 |              3.9 |                  75 |                        164 |               5.6 |             1 |              9.3 |            64 |                4.16 |              139 |                 5.3 |                   7.4 |                     77 |                                      0 |                                      0 |                                       0 |                                       1 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83742 |        64.5 |             151.3 |                  93.3 |                31.5 |             74 |        120 |          70 |              5.7 |                 107 |                        190 |               5.6 |             1 |             10.3 |            51 |                4.31 |              138 |                 3.1 |                   7.4 |                    295 |                                      0 |                                      0 |                                       1 |                                       0 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83744 |       108.3 |             179.4 |                 116   |                38.5 |             70 |        178 |         116 |            222   |                 204 |                        145 |               7.6 |             0 |              9.5 |           137 |                4.5  |              140 |                 4.1 |                   6.9 |                    121 |                                      0 |                                      0 |                                       0 |                                       0 |                             0 |                            0 |                                 0 |                                       0 |                                      0 |
|  83747 |        86.2 |             176.7 |                 104.3 |                33.6 |             68 |        144 |          94 |             57.6 |                 148 |                        242 |               6.2 |             0 |              9.3 |            55 |                4.27 |              138 |                 3.6 |                   6.8 |                    497 |                                      0 |                                      0 |                                       2 |                                       0 |                             0 |                            0 |                                 0 |                                       0 |                                      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
source_5.csv
source_6.csv
source_7.csv
test: test_0.csv
test_1.csv
test_2.csv
test_3.csv
test_4.csv
test_5.csv
test_6.csv
test_7.csv