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:
|   zipcode | businesses             |   counts |
|----------:|:-----------------------|---------:|
|     10001 | Debt Collection Agency |        5 |
|     10003 | Debt Collection Agency |        2 |
|     10004 | Debt Collection Agency |        3 |
|     10005 | Debt Collection Agency |        1 |
|     10006 | Debt Collection Agency |        4 |
|     10007 | Debt Collection Agency |        1 |
|     10010 | Debt Collection Agency |        1 |
|     10011 | Debt Collection Agency |        1 |
|     10013 | Debt Collection Agency |        1 |
|     10016 | Debt Collection Agency |        5 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| boro   |   zipcode |
|:-------|----------:|
| Bronx  |     10453 |
| Bronx  |     10457 |
| Bronx  |     10460 |
| Bronx  |     10458 |
| Bronx  |     10467 |
| Bronx  |     10468 |
| Bronx  |     10451 |
| Bronx  |     10452 |
| Bronx  |     10456 |
| Bronx  |     10454 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|   zipcode | businesses   |   counts |
|----------:|:-------------|---------:|
|     10001 | Pawnbroker   |        1 |
|     10002 | Pawnbroker   |        5 |
|     10005 | Pawnbroker   |        1 |
|     10009 | Pawnbroker   |        1 |
|     10010 | Pawnbroker   |        2 |
|     10011 | Pawnbroker   |        1 |
|     10017 | Pawnbroker   |        5 |
|     10018 | Pawnbroker   |        2 |
|     10019 | Pawnbroker   |        1 |
|     10020 | Pawnbroker   |        2 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
|   zipcode | businesses              |   counts |
|----------:|:------------------------|---------:|
|     10001 | Cigarette Retail Dealer |       98 |
|     10002 | Cigarette Retail Dealer |       77 |
|     10003 | Cigarette Retail Dealer |       78 |
|     10004 | Cigarette Retail Dealer |       25 |
|     10005 | Cigarette Retail Dealer |       22 |
|     10006 | Cigarette Retail Dealer |        8 |
|     10007 | Cigarette Retail Dealer |       38 |
|     10009 | Cigarette Retail Dealer |       64 |
|     10010 | Cigarette Retail Dealer |       45 |
|     10011 | Cigarette Retail Dealer |       69 |


Table #5
Filename: source_4.csv
Sample Rows in Markdown:
|   zipcode | businesses    |   counts |
|----------:|:--------------|---------:|
|     10001 | Sidewalk Cafe |       10 |
|     10002 | Sidewalk Cafe |       14 |
|     10003 | Sidewalk Cafe |       85 |
|     10004 | Sidewalk Cafe |        1 |
|     10006 | Sidewalk Cafe |        1 |
|     10007 | Sidewalk Cafe |        4 |
|     10009 | Sidewalk Cafe |       28 |
|     10010 | Sidewalk Cafe |       21 |
|     10011 | Sidewalk Cafe |       44 |
|     10012 | Sidewalk Cafe |       60 |


Table #6
Filename: source_5.csv
Sample Rows in Markdown:
|   zipcode |   businesses |
|----------:|-------------:|
|     10804 |           29 |
|     10805 |           36 |
|     10901 |           20 |
|     10913 |           18 |
|     10914 |            2 |
|     10916 |            8 |
|     10917 |            2 |
|     10918 |            5 |
|     10920 |           15 |
|     10921 |            1 |


Target Schema:
|   zipcode | businesses_x   |   counts_x | businesses_y   |   counts_y | businesses_x_5         |   counts_x_6 | businesses_y_7          |   counts_y_8 | boro      |   businesses |
|----------:|:---------------|-----------:|:---------------|-----------:|:-----------------------|-------------:|:------------------------|-------------:|:----------|-------------:|
|     10001 | Sidewalk Cafe  |         10 | Pawnbroker     |          1 | Debt Collection Agency |            5 | Cigarette Retail Dealer |           98 | Manhattan |          592 |
|     10010 | Sidewalk Cafe  |         21 | Pawnbroker     |          2 | Debt Collection Agency |            1 | Cigarette Retail Dealer |           45 | Manhattan |          308 |
|     10011 | Sidewalk Cafe  |         44 | Pawnbroker     |          1 | Debt Collection Agency |            1 | Cigarette Retail Dealer |           69 | Manhattan |          477 |
|     10017 | Sidewalk Cafe  |          7 | Pawnbroker     |          5 | Debt Collection Agency |            4 | Cigarette Retail Dealer |           57 | Manhattan |          300 |
|     10018 | Sidewalk Cafe  |          1 | Pawnbroker     |          2 | Debt Collection Agency |            2 | Cigarette Retail Dealer |           74 | Manhattan |          352 |
|     10019 | Sidewalk Cafe  |         41 | Pawnbroker     |          1 | Debt Collection Agency |            3 | Cigarette Retail Dealer |          104 | Manhattan |          546 |
|     10022 | Sidewalk Cafe  |         28 | Pawnbroker     |          3 | Debt Collection Agency |            1 | Cigarette Retail Dealer |           72 | Manhattan |          463 |
|     10032 | Sidewalk Cafe  |          6 | Pawnbroker     |          1 | Debt Collection Agency |            1 | Cigarette Retail Dealer |           53 | Manhattan |          269 |
|     10036 | Sidewalk Cafe  |         33 | Pawnbroker     |         32 | Debt Collection Agency |            2 | Cigarette Retail Dealer |           74 | Manhattan |          752 |
|     10458 | Sidewalk Cafe  |          6 | Pawnbroker     |         15 | Debt Collection Agency |            1 | Cigarette Retail Dealer |           95 | Bronx     |          535 |

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