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:
|   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 #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 |
|----------:|:------------------------|---------:|
|     10474 | Cigarette Retail Dealer |       21 |
|     10475 | Cigarette Retail Dealer |       17 |
|     11001 | Cigarette Retail Dealer |        1 |
|     11004 | Cigarette Retail Dealer |        8 |
|     11005 | Cigarette Retail Dealer |        2 |
|     11040 | Cigarette Retail Dealer |        1 |
|     11101 | Cigarette Retail Dealer |       64 |
|     11102 | Cigarette Retail Dealer |       38 |
|     11103 | Cigarette Retail Dealer |       56 |
|     11104 | Cigarette Retail Dealer |       36 |


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

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