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:
| Name                          |   tram km per capita |   GWP_bustram |
|:------------------------------|---------------------:|--------------:|
| Belgisch Park                 |              1.91214 |       65.78   |
| Westbroekpark                 |              1.98356 |       68.2371 |
| Duttendel                     |              1.86906 |       64.2979 |
| Nassaubuurt                   |              1.78062 |       61.2556 |
| Uilennest                     |              1.77127 |       60.9339 |
| Duinzigt                      |              1.96761 |       67.6883 |
| Waalsdorp                     |              1.76117 |       60.5864 |
| Arendsdorp                    |              1.80894 |       62.2297 |
| Van Hoytemastraat en omgeving |              1.72621 |       59.3839 |
| Archipelbuurt                 |              1.80433 |       62.0712 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| Name                 |   BUURTCODE |   Population |   food_consumed |   Income per capita |   Amount per capita |
|:---------------------|------------:|-------------:|----------------:|--------------------:|--------------------:|
| Huygenspark          |          18 |         7895 |     2.41123e+07 |               17300 |             3054.12 |
| Rivierenbuurt-Zuid   |          62 |          850 |     2.66535e+06 |               18400 |             3135.7  |
| Rivierenbuurt-Noord  |          63 |         3690 |     1.13708e+07 |               24600 |             3081.51 |
| Kortenbos            |          11 |         7275 |     2.27837e+07 |               26600 |             3131.78 |
| Voorhout             |          12 |         2355 |     7.51356e+06 |               47000 |             3190.47 |
| Uilebomen            |          13 |         3180 |     9.97693e+06 |               28300 |             3137.4  |
| Zuidwal              |          14 |         6885 |     2.17568e+07 |               24000 |             3160.03 |
| Schildersbuurt-West  |          15 |        14115 |     4.15296e+07 |               12800 |             2942.23 |
| Schildersbuurt-Noord |          16 |         9985 |     2.93502e+07 |               12900 |             2939.43 |
| Schildersbuurt-Oost  |          17 |         7230 |     2.11906e+07 |               12200 |             2930.92 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| Name                          | Type   |   green gas |   nongreen gas |   BUURTCODE |
|:------------------------------|:-------|------------:|---------------:|------------:|
| Belgisch Park                 | Buurt  |     420.708 |        281.406 |          71 |
| Westbroekpark                 | Buurt  |     524.621 |        451.345 |          73 |
| Duttendel                     | Buurt  |     537.39  |        435.866 |          74 |
| Nassaubuurt                   | Buurt  |     532.005 |        400.302 |          48 |
| Uilennest                     | Buurt  |     441.836 |        348.759 |          75 |
| Duinzigt                      | Buurt  |     540.592 |        493.176 |          76 |
| Waalsdorp                     | Buurt  |     471.274 |        351.062 |          77 |
| Arendsdorp                    | Buurt  |     455.799 |        353.09  |          78 |
| Van Hoytemastraat en omgeving | Buurt  |     464.425 |        334.727 |          79 |
| Archipelbuurt                 | Buurt  |     453.781 |        340.58  |          46 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
| Name                          | type   |   Water consumption |   Household size |   Average area |   BUURTCODE |
|:------------------------------|:-------|--------------------:|-----------------:|---------------:|------------:|
| Belgisch Park                 | Buurt  |             71.4157 |          1.95125 |        131.563 |          71 |
| Westbroekpark                 | Buurt  |             78.9993 |          1.97753 |        245.537 |          73 |
| Duttendel                     | Buurt  |             81.443  |          2.31183 |        245.537 |          74 |
| Nassaubuurt                   | Buurt  |             82.0185 |          2.16667 |        184.087 |          48 |
| Uilennest                     | Buurt  |             74.1542 |          1.83406 |        184.087 |          75 |
| Duinzigt                      | Buurt  |             74.2058 |          1.75088 |        184.087 |          76 |
| Waalsdorp                     | Buurt  |             81.2303 |          2.35913 |        184.087 |          77 |
| Arendsdorp                    | Buurt  |             81.3463 |          2.50962 |        184.087 |          78 |
| Van Hoytemastraat en omgeving | Buurt  |             78.2351 |          2.30244 |        184.087 |          79 |
| Archipelbuurt                 | Buurt  |             77.3971 |          1.81278 |        157.241 |          46 |


Table #5
Filename: source_4.csv
Sample Rows in Markdown:
| Name                          |   train km per capita |   GWP_train |
|:------------------------------|----------------------:|------------:|
| Belgisch Park                 |               5.64751 |     95.6462 |
| Westbroekpark                 |               5.84638 |     99.0142 |
| Duttendel                     |               5.61677 |     95.1255 |
| Nassaubuurt                   |               5.38928 |     91.2729 |
| Uilennest                     |               5.43987 |     92.1296 |
| Duinzigt                      |               5.85457 |     99.153  |
| Waalsdorp                     |               5.31321 |     89.9845 |
| Arendsdorp                    |               5.42918 |     91.9487 |
| Van Hoytemastraat en omgeving |               5.26522 |     89.1718 |
| Archipelbuurt                 |               5.48611 |     92.9127 |


Table #6
Filename: source_5.csv
Sample Rows in Markdown:
| Name                          | Type   |   green electricity |   nongreen electricity |   BUURTCODE |
|:------------------------------|:-------|--------------------:|-----------------------:|------------:|
| Belgisch Park                 | Buurt  |             822.991 |                550.488 |          71 |
| Westbroekpark                 | Buurt  |             877.992 |                755.36  |          73 |
| Duttendel                     | Buurt  |             924.31  |                749.69  |          74 |
| Nassaubuurt                   | Buurt  |             821.711 |                618.289 |          48 |
| Uilennest                     | Buurt  |             828.824 |                654.224 |          75 |
| Duinzigt                      | Buurt  |             770.568 |                702.979 |          76 |
| Waalsdorp                     | Buurt  |             779.789 |                580.88  |          77 |
| Arendsdorp                    | Buurt  |             687.066 |                532.244 |          78 |
| Van Hoytemastraat en omgeving | Buurt  |             772.36  |                556.666 |          79 |
| Archipelbuurt                 | Buurt  |             768.907 |                577.093 |          46 |


Table #7
Filename: source_6.csv
Sample Rows in Markdown:
| Name                          |   BUURTCODE |   car km per capita |   GWP_car |
|:------------------------------|------------:|--------------------:|----------:|
| Belgisch Park                 |          71 |             19.973  |   2414.06 |
| Westbroekpark                 |          73 |             18.4228 |   2226.69 |
| Duttendel                     |          74 |             19.2934 |   2331.91 |
| Nassaubuurt                   |          48 |             19.8885 |   2403.84 |
| Uilennest                     |          75 |             20.2696 |   2449.91 |
| Duinzigt                      |          76 |             18.3061 |   2212.59 |
| Waalsdorp                     |          77 |             19.119  |   2310.84 |
| Arendsdorp                    |          78 |             18.9598 |   2291.6  |
| Van Hoytemastraat en omgeving |          79 |             19.9884 |   2415.92 |
| Archipelbuurt                 |          46 |             20.721  |   2504.46 |


Target Schema:
| Name                          |   BUURTCODE_x_x |   Population |   food_consumed |   Income per capita |   Amount per capita | Type_x   |   green electricity |   nongreen electricity |   BUURTCODE_y_x | Type_y   |   green gas |   nongreen gas |   BUURTCODE | type   |   Water consumption |   Household size |   Average area |   BUURTCODE_x_y |   BUURTCODE_y_y |   car km per capita |   GWP_car |   train km per capita |   GWP_train |   tram km per capita |   GWP_bustram |
|:------------------------------|----------------:|-------------:|----------------:|--------------------:|--------------------:|:---------|--------------------:|-----------------------:|----------------:|:---------|------------:|---------------:|------------:|:-------|--------------------:|-----------------:|---------------:|----------------:|----------------:|--------------------:|----------:|----------------------:|------------:|---------------------:|--------------:|
| Belgisch Park                 |              71 |         8205 |     2.53013e+07 |               33400 |             3083.64 | Buurt    |             822.991 |                550.488 |              71 | Buurt    |     420.708 |        281.406 |          71 | Buurt  |             71.4157 |          1.95125 |        131.563 |              71 |              71 |             19.973  |   2414.06 |               5.64751 |     95.6462 |              1.91214 |       65.78   |
| Westbroekpark                 |              73 |          880 |     2.76745e+06 |               53000 |             3144.82 | Buurt    |             877.992 |                755.36  |              73 | Buurt    |     524.621 |        451.345 |          73 | Buurt  |             78.9993 |          1.97753 |        245.537 |              73 |              73 |             18.4228 |   2226.69 |               5.84638 |     99.0142 |              1.98356 |       68.2371 |
| Duttendel                     |              74 |         1075 |     3.34466e+06 |               55800 |             3111.31 | Buurt    |             924.31  |                749.69  |              74 | Buurt    |     537.39  |        435.866 |          74 | Buurt  |             81.443  |          2.31183 |        245.537 |              74 |              74 |             19.2934 |   2331.91 |               5.61677 |     95.1255 |              1.86906 |       64.2979 |
| Nassaubuurt                   |              48 |         1625 |     4.91582e+06 |               56200 |             3025.12 | Buurt    |             821.711 |                618.289 |              48 | Buurt    |     532.005 |        400.302 |          48 | Buurt  |             82.0185 |          2.16667 |        184.087 |              48 |              48 |             19.8885 |   2403.84 |               5.38928 |     91.2729 |              1.78062 |       61.2556 |
| Uilennest                     |              75 |         2100 |     6.53045e+06 |               41600 |             3109.74 | Buurt    |             828.824 |                654.224 |              75 | Buurt    |     441.836 |        348.759 |          75 | Buurt  |             74.1542 |          1.83406 |        184.087 |              75 |              75 |             20.2696 |   2449.91 |               5.43987 |     92.1296 |              1.77127 |       60.9339 |
| Duinzigt                      |              76 |         2495 |     7.89594e+06 |               44200 |             3164.7  | Buurt    |             770.568 |                702.979 |              76 | Buurt    |     540.592 |        493.176 |          76 | Buurt  |             74.2058 |          1.75088 |        184.087 |              76 |              76 |             18.3061 |   2212.59 |               5.85457 |     99.153  |              1.96761 |       67.6883 |
| Waalsdorp                     |              77 |         3810 |     1.13982e+07 |               49100 |             2991.64 | Buurt    |             779.789 |                580.88  |              77 | Buurt    |     471.274 |        351.062 |          77 | Buurt  |             81.2303 |          2.35913 |        184.087 |              77 |              77 |             19.119  |   2310.84 |               5.31321 |     89.9845 |              1.76117 |       60.5864 |
| Arendsdorp                    |              78 |         1305 |     3.93687e+06 |               51600 |             3016.76 | Buurt    |             687.066 |                532.244 |              78 | Buurt    |     455.799 |        353.09  |          78 | Buurt  |             81.3463 |          2.50962 |        184.087 |              78 |              78 |             18.9598 |   2291.6  |               5.42918 |     91.9487 |              1.80894 |       62.2297 |
| Van Hoytemastraat en omgeving |              79 |         2360 |     7.06729e+06 |               42500 |             2994.61 | Buurt    |             772.36  |                556.666 |              79 | Buurt    |     464.425 |        334.727 |          79 | Buurt  |             78.2351 |          2.30244 |        184.087 |              79 |              79 |             19.9884 |   2415.92 |               5.26522 |     89.1718 |              1.72621 |       59.3839 |
| Archipelbuurt                 |              46 |         6100 |     1.89361e+07 |               52000 |             3104.27 | Buurt    |             768.907 |                577.093 |              46 | Buurt    |     453.781 |        340.58  |          46 | Buurt  |             77.3971 |          1.81278 |        157.241 |              46 |              46 |             20.721  |   2504.46 |               5.48611 |     92.9127 |              1.80433 |       62.0712 |

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