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:
| AccountId            | CloseDate           | Amount   | CreatedDate_x       | OwnerId            | Type   | Opportunity_ID__c   | Name                           | StageName                  | OpportunityId       |   SplitPercentage | SplitOwnerId       | SplitAmount   | CreatedDate_y       | Full_Name__c   | Sales_Team__c   | Sales_Territory__c   | Id                 | ToDate              |   CreatedDateDiff | CloseDateDiff     |   3mos_Created |   6mos_Created |   9mos_Created |   12mos_Created |   3mos_Closed |   6mos_Closed |   9mos_Closed |   12mos_Closed |   CY_Created |   CY_Closed |
|:---------------------|:--------------------|:---------|:--------------------|:-------------------|:-------|:--------------------|:-------------------------------|:---------------------------|:--------------------|------------------:|:-------------------|:--------------|:--------------------|:---------------|:----------------|:---------------------|:-------------------|:--------------------|------------------:|:------------------|---------------:|---------------:|---------------:|----------------:|--------------:|--------------:|--------------:|---------------:|-------------:|------------:|
| 001E000000IIp5nU80m  | 2016-05-04 00:00:00 | 5221.84  | 2016-04-09 12:57:43 | 005E0000008XxIwj7u | NBEC   | 006E000000yxT0Ic1Ih | Blue Cross Blue Shield Wyoming | Closed Lost                | 006E000000yxT0Ic1Ih |                50 | 005E0000008XxIwj7u | 2610.92       | 2016-04-09 12:57:43 | Dacia Brymer   | Inside          | SMB                  | 005E0000008XxIwj7u | 2017-01-01 00:00:00 |           8.75451 | 7.950881948294626 |              0 |              0 |              1 |               1 |             0 |             0 |             0 |              0 |            1 |           0 |
| 001E000000e5J0d0IrWn |                     | 12973.9  | 2016-04-05 20:27:37 | 005E0000008XxIwj7u | NB     | 006E000000OVlyj806V | Hubbell Incorporated           | 2 - Discover/Scope         | 006E000000OVlyj806V |                50 | 005E0000008XxIwj7u | 6486.95       | 2016-04-05 20:27:37 | Dacia Brymer   | Inside          | SMB                  | 005E0000008XxIwj7u | 2017-01-01 00:00:00 |           8.87566 |                   |              0 |              0 |              1 |               1 |             0 |             0 |             0 |              0 |            1 |           0 |
| 001E000000OOtKd801f  |                     | 5123.71  | 2016-03-21 16:54:22 | 005E0000008XxIwj7u | NB     | 006E000000vtrzT0Oa9 | Paccar Winch Inc               | 5 - Business Case/Proposal | 006E000000vtrzT0Oa9 |               100 | 005E0000008XxIwj7u | 5123.71       | 2016-03-21 16:54:22 | Dacia Brymer   | Inside          | SMB                  | 005E0000008XxIwj7u | 2017-01-01 00:00:00 |           9.37335 |                   |              0 |              0 |              0 |               1 |             0 |             0 |             0 |              0 |            1 |           0 |
| 001E000000uPj2PtVa   | 2016-05-04 00:00:00 | 46238.75 | 2016-03-08 00:49:51 | 005E0000008XxIwj7u | NB     | 006E000000KGaZ9oYU  | Harbor Enterprises  Inc        | Disqualified               | 006E000000KGaZ9oYU  |               100 | 005E0000008XxIwj7u | 46238.75      | 2016-03-08 00:49:51 | Dacia Brymer   | Inside          | SMB                  | 005E0000008XxIwj7u | 2017-01-01 00:00:00 |           9.82247 | 7.950881948294626 |              0 |              0 |              0 |               1 |             0 |             0 |             0 |              0 |            1 |           0 |
| 001E000000UT0tu2J024 |                     | 14728.38 | 2016-02-04 20:50:14 | 005E0000008XxIwj7u | NBEC   | 006E000000yHGzSliR  | Attachmate Corporation         | 2 - Discover/Scope         | 006E000000yHGzSliR  |                50 | 005E0000008XxIwj7u | 7364.19       | 2016-02-04 20:50:14 | Dacia Brymer   | Inside          | SMB                  | 005E0000008XxIwj7u | 2017-01-01 00:00:00 |          10.8793  |                   |              0 |              0 |              0 |               1 |             0 |             0 |             0 |              0 |            1 |           0 |
| 001E000000s57xbPv7   |                     | 77606.28 | 2016-01-26 04:12:48 | 005E0000008XxIwj7u | NBEC   | 006E00000013OfqIPb  | Vcu Health System Authority    | 2 - Discover/Scope         | 006E00000013OfqIPb  |                50 | 005E0000008XxIwj7u | 38803.14      | 2016-01-26 04:12:48 | Dacia Brymer   | Inside          | SMB                  | 005E0000008XxIwj7u | 2017-01-01 00:00:00 |          11.1977  |                   |              0 |              0 |              0 |               1 |             0 |             0 |             0 |              0 |            1 |           0 |
| 001E000000svy2punT   | 2016-05-04 00:00:00 |          | 2016-01-22 12:43:46 | 005E0000008XxIwj7u | NB     | 006E0000007Xwn0GkmJ | Vermeer Manufacturing Company  | 7 - Closed Won             | 006E0000007Xwn0GkmJ |               100 | 005E0000008XxIwj7u |               | 2016-01-22 12:43:46 | Dacia Brymer   | Inside          | SMB                  | 005E0000008XxIwj7u | 2017-01-01 00:00:00 |          11.3175  | 7.950881948294626 |              0 |              0 |              0 |               1 |             0 |             0 |             1 |              1 |            1 |           1 |
| 001E0000003hcH38sp   |                     | 6808.99  | 2016-04-19 06:49:31 | 005E000000QZJHnX8u | NB     | 006E000000NoKn0fzNt | Educate  Inc                   | 5 - Business Case/Proposal | 006E000000NoKn0fzNt |               100 | 005E000000QZJHnX8u | 6808.99       | 2016-04-19 06:49:31 | Thuy Mattocks  | Field           | Commercial           | 005E000000QZJHnX8u | 2017-01-01 00:00:00 |           8.43436 |                   |              0 |              0 |              1 |               1 |             0 |             0 |             0 |              0 |            1 |           0 |
| 001E0000002yx3maNU   | 2016-05-04 00:00:00 | 5256.95  | 2016-04-19 00:43:40 | 005E000000QZJHnX8u | NBEC   | 006E000000hiMJ0dLzY | Saint Alphonsus Regional Medic | 7 - Closed Won             | 006E000000hiMJ0dLzY |               100 | 005E000000QZJHnX8u | 5256.95       | 2016-04-19 00:43:40 | Thuy Mattocks  | Field           | Commercial           | 005E000000QZJHnX8u | 2017-01-01 00:00:00 |           8.44271 | 7.950881948294626 |              0 |              0 |              1 |               1 |             0 |             0 |             1 |              1 |            1 |           1 |
| 001E00000036jzyJXW   | 2016-05-04 00:00:00 | 4707.41  | 2016-04-17 01:46:30 | 005E000000QZJHnX8u | NB     | 006E000000LqW6UeyK  | Jennie-O Turkey Store  Inc     | Disqualified               | 006E000000LqW6UeyK  |               100 | 005E000000QZJHnX8u | 4707.41       | 2016-04-17 01:46:30 | Thuy Mattocks  | Field           | Commercial           | 005E000000QZJHnX8u | 2017-01-01 00:00:00 |           8.50699 | 7.950881948294626 |              0 |              0 |              1 |               1 |             0 |             0 |             0 |              0 |            1 |           0 |


Target Schema:
| Sales_Team__c   | Type   | ToDate              | StageName      | AccountId           | Opportunity_ID__c   |   SplitAmount | Sales_Territory__c   | CreatedDate_y       | Full_Name__c   |   SplitPercentage |   CloseDateDiff |   Amount |   CreatedDateDiff | Name                       | CloseDate           | SplitOwnerId       | OwnerId            | OpportunityId       | CreatedDate_x       | Id                 | variable      | Split_TimeFrame   | Closed   | Created   |
|:----------------|:-------|:--------------------|:---------------|:--------------------|:--------------------|--------------:|:---------------------|:--------------------|:---------------|------------------:|----------------:|---------:|------------------:|:---------------------------|:--------------------|:-------------------|:-------------------|:--------------------|:--------------------|:-------------------|:--------------|:------------------|:---------|:----------|
| Field           | NB     | 2017-01-01 00:00:00 | 7 - Closed Won | 001E000000Gsx0nz3jX | 006E000000m80isIqKM |       4036.11 | Commercial           | 2016-04-22 07:55:34 | Kay Bella      |               100 |         7.95088 |  4036.11 |           8.33429 | Avalonbay Communities  Inc | 2016-05-04 00:00:00 | 005E000000Sw83GTO6 | 005E000000Sw83GTO6 | 006E000000m80isIqKM | 2016-04-22 07:55:34 | 005E000000Sw83GTO6 | 12mos_Closed  | 12mos             | 1.0      |           |
| Field           | NB     | 2017-01-01 00:00:00 | 7 - Closed Won | 001E000000Gsx0nz3jX | 006E000000m80isIqKM |       4036.11 | Commercial           | 2016-04-22 07:55:34 | Kay Bella      |               100 |         7.95088 |  4036.11 |           8.33429 | Avalonbay Communities  Inc | 2016-05-04 00:00:00 | 005E000000Sw83GTO6 | 005E000000Sw83GTO6 | 006E000000m80isIqKM | 2016-04-22 07:55:34 | 005E000000Sw83GTO6 | 12mos_Created | 12mos             |          | 1.0       |
| Field           | NB     | 2017-01-01 00:00:00 | 7 - Closed Won | 001E000000Gsx0nz3jX | 006E000000m80isIqKM |       4036.11 | Commercial           | 2016-04-22 07:55:34 | Kay Bella      |               100 |         7.95088 |  4036.11 |           8.33429 | Avalonbay Communities  Inc | 2016-05-04 00:00:00 | 005E000000Sw83GTO6 | 005E000000Sw83GTO6 | 006E000000m80isIqKM | 2016-04-22 07:55:34 | 005E000000Sw83GTO6 | 3mos_Closed   | 3mos              | 0.0      |           |
| Field           | NB     | 2017-01-01 00:00:00 | 7 - Closed Won | 001E000000Gsx0nz3jX | 006E000000m80isIqKM |       4036.11 | Commercial           | 2016-04-22 07:55:34 | Kay Bella      |               100 |         7.95088 |  4036.11 |           8.33429 | Avalonbay Communities  Inc | 2016-05-04 00:00:00 | 005E000000Sw83GTO6 | 005E000000Sw83GTO6 | 006E000000m80isIqKM | 2016-04-22 07:55:34 | 005E000000Sw83GTO6 | 3mos_Created  | 3mos              |          | 0.0       |
| Field           | NB     | 2017-01-01 00:00:00 | 7 - Closed Won | 001E000000Gsx0nz3jX | 006E000000m80isIqKM |       4036.11 | Commercial           | 2016-04-22 07:55:34 | Kay Bella      |               100 |         7.95088 |  4036.11 |           8.33429 | Avalonbay Communities  Inc | 2016-05-04 00:00:00 | 005E000000Sw83GTO6 | 005E000000Sw83GTO6 | 006E000000m80isIqKM | 2016-04-22 07:55:34 | 005E000000Sw83GTO6 | 6mos_Closed   | 6mos              | 0.0      |           |
| Field           | NB     | 2017-01-01 00:00:00 | 7 - Closed Won | 001E000000Gsx0nz3jX | 006E000000m80isIqKM |       4036.11 | Commercial           | 2016-04-22 07:55:34 | Kay Bella      |               100 |         7.95088 |  4036.11 |           8.33429 | Avalonbay Communities  Inc | 2016-05-04 00:00:00 | 005E000000Sw83GTO6 | 005E000000Sw83GTO6 | 006E000000m80isIqKM | 2016-04-22 07:55:34 | 005E000000Sw83GTO6 | 6mos_Created  | 6mos              |          | 0.0       |
| Field           | NB     | 2017-01-01 00:00:00 | 7 - Closed Won | 001E000000Gsx0nz3jX | 006E000000m80isIqKM |       4036.11 | Commercial           | 2016-04-22 07:55:34 | Kay Bella      |               100 |         7.95088 |  4036.11 |           8.33429 | Avalonbay Communities  Inc | 2016-05-04 00:00:00 | 005E000000Sw83GTO6 | 005E000000Sw83GTO6 | 006E000000m80isIqKM | 2016-04-22 07:55:34 | 005E000000Sw83GTO6 | 9mos_Closed   | 9mos              | 1.0      |           |
| Field           | NB     | 2017-01-01 00:00:00 | 7 - Closed Won | 001E000000Gsx0nz3jX | 006E000000m80isIqKM |       4036.11 | Commercial           | 2016-04-22 07:55:34 | Kay Bella      |               100 |         7.95088 |  4036.11 |           8.33429 | Avalonbay Communities  Inc | 2016-05-04 00:00:00 | 005E000000Sw83GTO6 | 005E000000Sw83GTO6 | 006E000000m80isIqKM | 2016-04-22 07:55:34 | 005E000000Sw83GTO6 | 9mos_Created  | 9mos              |          | 1.0       |
| Field           | NB     | 2017-01-01 00:00:00 | 7 - Closed Won | 001E000000Gsx0nz3jX | 006E000000m80isIqKM |       4036.11 | Commercial           | 2016-04-22 07:55:34 | Kay Bella      |               100 |         7.95088 |  4036.11 |           8.33429 | Avalonbay Communities  Inc | 2016-05-04 00:00:00 | 005E000000Sw83GTO6 | 005E000000Sw83GTO6 | 006E000000m80isIqKM | 2016-04-22 07:55:34 | 005E000000Sw83GTO6 | CY_Closed     | CY                | 1.0      |           |
| Field           | NB     | 2017-01-01 00:00:00 | 7 - Closed Won | 001E000000Gsx0nz3jX | 006E000000m80isIqKM |       4036.11 | Commercial           | 2016-04-22 07:55:34 | Kay Bella      |               100 |         7.95088 |  4036.11 |           8.33429 | Avalonbay Communities  Inc | 2016-05-04 00:00:00 | 005E000000Sw83GTO6 | 005E000000Sw83GTO6 | 006E000000m80isIqKM | 2016-04-22 07:55:34 | 005E000000Sw83GTO6 | CY_Created    | CY                |          | 1.0       |

Return only the final code in markdown codeblock format, without any additional text or explanation. 



target: target.csv
train: source_0.csv
test: test_0.csv