Task: Transform-by-output-target-schema (source dataset: commercial-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:
|   CustomerID |   1 | 2              | 3   |
|-------------:|----:|:---------------|:----|
|            2 | 100 | Corporate      | No  |
|            5 | 100 | Home Office    | No  |
|            6 | 106 | Home Office    | No  |
|            8 | 101 | Home Office    | No  |
|           11 | 106 | Home Office    | No  |
|           12 | 108 | Home Office    | No  |
|           14 | 105 | Small Business | No  |
|           15 | 104 | Small Business | Yes |
|           18 | 104 | Small Business | No  |
|           24 | 105 | Corporate      | No  |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   CustomerID | First Name   | Last Name    | Address              | City      | State   |   Zip |     Lat |      Lon |
|-------------:|:-------------|:-------------|:---------------------|:----------|:--------|------:|--------:|---------:|
|         1686 | LEA          | FOWLER       | 5301 S BIRCH CT      | LITTLETON | CO      | 80121 | 39.6222 | -104.932 |
|         1687 | YVETTE       | KENT         | 4871 S JOHNSON ST    | LITTLETON | CO      | 80123 | 39.629  | -105.109 |
|         1689 | DONNA        | SCHARFENBERG | 5565 E BAILS DR      | DENVER    | CO      | 80222 | 39.6831 | -104.923 |
|         1690 | PETRA        | VALDEZ       | 2790 W ELLSWORTH AVE | DENVER    | CO      | 80219 | 39.7165 | -105.023 |
|         1692 | DOROTHY      | THURBER      | 140 DOVER ST         | DENVER    | CO      | 80226 | 39.7193 | -105.094 |
|         1693 | CHERLYN      | DATEMA       | 11773 W 76TH LN      | ARVADA    | CO      | 80005 | 39.8383 | -105.13  |
|         1695 | VIOLET       | ROGERS       | 555 ESTES ST         | DENVER    | CO      | 80226 | 39.7248 | -105.095 |
|         1696 | EVELYN       | HAASE        | 276 MOLINE CT        | AURORA    | CO      | 80010 | 39.7198 | -104.857 |
|         1697 | KATHY        | SANDER       | 4620 S ENSENADA ST   | AURORA    | CO      | 80015 | 39.6334 | -104.761 |
|         1699 | FLORENCE     | ALLOWAY      | 2990 S LIPAN ST      | ENGLEWOOD | CO      | 80110 | 39.6621 | -104.999 |


Target Schema:
|   CustomerID |   1 | 2              | 3   | First Name   | Last Name   | Address             | City      | State   |   Zip |     Lat |      Lon |
|-------------:|----:|:---------------|:----|:-------------|:------------|:--------------------|:----------|:--------|------:|--------:|---------:|
|            2 | 100 | Corporate      | No  | JEAN         | SMITH       | 376 S JASMINE ST    | DENVER    | CO      | 80224 | 39.7097 | -104.919 |
|            5 | 100 | Home Office    | No  | LINDA        | TREVINO     | 5360 ZUNI ST        | DENVER    | CO      | 80221 | 39.7939 | -105.016 |
|            6 | 106 | Home Office    | No  | H            | MACK        | 1599 WILLIAMS ST    | DENVER    | CO      | 80218 | 39.7416 | -104.966 |
|            8 | 101 | Home Office    | No  | PHYLLIS      | WALKER      | 7225 S GAYLORD ST   | LITTLETON | CO      | 80122 | 39.5871 | -104.962 |
|           11 | 106 | Home Office    | No  | MARIA        | GONZALEZ    | 3883 QUITMAN ST     | DENVER    | CO      | 80212 | 39.7707 | -105.041 |
|           12 | 108 | Home Office    | No  | WANDA        | MAYBERRY    | 1965 YUKON ST       | DENVER    | CO      | 80214 | 39.7469 | -105.083 |
|           14 | 105 | Small Business | No  | KATHLEEN     | KIRBACH     | 2343 S VAUGHN WAY   | AURORA    | CO      | 80014 | 39.6743 | -104.835 |
|           15 | 104 | Small Business | Yes | BERNADETTE   | MCKALE      | 4288 S RICHFIELD ST | AURORA    | CO      | 80013 | 39.6402 | -104.785 |
|           18 | 104 | Small Business | No  | MICHAELA     | BOLLWITT    | 4034 S CARSON ST    | AURORA    | CO      | 80014 | 39.645  | -104.823 |
|           24 | 105 | Corporate      | No  | ROBIN        | WALLIN      | 2855 ADAMS ST       | DENVER    | CO      | 80205 | 39.7576 | -104.949 |

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