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:
|     ROW_WID |   KEYWORDS_NUM |
|------------:|---------------:|
| 3.07578e+08 |              1 |
| 3.07587e+08 |              5 |
| 3.07576e+08 |              1 |
| 3.07583e+08 |              1 |
| 3.07582e+08 |              1 |
| 3.07576e+08 |              5 |
| 3.07575e+08 |              2 |
| 3.07583e+08 |              1 |
| 3.07581e+08 |             11 |
| 3.07577e+08 |              7 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|     ROW_WID |   COLLECTION_EVENTS_NUM |
|------------:|------------------------:|
| 1.38895e+09 |                       2 |
| 6.82775e+08 |                       9 |
| 1.17744e+09 |                       5 |
| 1.11372e+09 |                       4 |
| 8.14872e+08 |                       2 |
| 3.10789e+08 |                       7 |
| 1.40886e+09 |                       2 |
| 4.72358e+08 |                       7 |
| 5.58006e+08 |                      22 |
| 7.48356e+08 |                      20 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|     ROW_WID |   INBOUND_CALLS_NUM |
|------------:|--------------------:|
| 3.07586e+08 |                   7 |
| 3.07578e+08 |                   1 |
| 3.07581e+08 |                  11 |
| 3.07587e+08 |                  12 |
| 3.07583e+08 |                   5 |
| 3.07576e+08 |                   1 |
| 3.11624e+08 |                   8 |
| 3.07583e+08 |                   1 |
| 3.07582e+08 |                   2 |
| 3.07576e+08 |                  10 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
|   CANCELED |   ROW_WID |   ACCNT_LOC |   ARPU | SES   |   HOME_PASSED | CUST_SINCE_DT   |   MONTHS_AGE | CANCEL_DT   | CITY     | POP   |
|-----------:|----------:|------------:|-------:|:------|--------------:|:----------------|-------------:|:------------|:---------|:------|
|          1 | 688525490 |     4219649 | 555.12 | C     |          3439 | 07-DIC-15       |        19.77 | 31-JUL-17   | MONCLOVA | MC    |
|          1 | 694259818 |     4221404 | 260.15 | D     |          1499 | 20-DIC-16       |         5.67 | 10-JUN-17   | MONCLOVA | MC    |
|          1 | 701127287 |     4223645 | 252.85 | C     |           860 | 11-ENE-16       |        19.64 | 31-AGO-17   | MONCLOVA | MC    |
|          1 | 706876069 |     4225286 | 489.35 | D     |          2085 | 28-DIC-15       |        18.6  | 16-JUL-17   | FRONTERA | MC    |
|          1 | 691968784 |     4220854 | 167.71 | D     |           753 | 17-DIC-15       |        17.66 | 07-JUN-17   | MONCLOVA | MC    |
|          1 | 706875737 |     4225230 | 587.88 | C     |          3439 | 04-ENE-16       |        19.5  | 20-AGO-17   | MONCLOVA | MC    |
|          1 | 734478098 |     4232883 | 301.97 | C     |          3273 | 04-FEB-16       |        17.53 | 21-JUL-17   | MONCLOVA | MC    |
|          1 | 698830028 |     4222607 | 430.22 | C     |          3439 | 09-FEB-16       |        17.7  | 31-JUL-17   | MONCLOVA | MC    |
|          1 | 696545780 |     4222171 | 583.21 | D     |           240 | 19-DIC-15       |        19.7  | 10-AGO-17   | MONCLOVA | MC    |
|          1 | 726405270 |     4230171 | 500.97 | C     |           284 | 30-MAY-16       |        12.51 | 15-JUN-17   | MONCLOVA | MC    |


Table #5
Filename: source_4.csv
Sample Rows in Markdown:
|     ROW_WID |   TECHSUPPORT_NUM |
|------------:|------------------:|
| 3.07574e+08 |                 4 |
| 3.07575e+08 |                 5 |
| 3.07575e+08 |                 1 |
| 3.07575e+08 |                 4 |
| 3.07575e+08 |                 1 |
| 3.07575e+08 |                 8 |
| 3.07575e+08 |                 6 |
| 3.07575e+08 |                 5 |
| 3.07576e+08 |                 1 |
| 3.07576e+08 |                 4 |


Table #6
Filename: source_5.csv
Sample Rows in Markdown:
|   CANCELED |    ROW_WID |   ACCNT_LOC |    ARPU | SES   |   HOME_PASSED | CUST_SINCE_DT   |   MONTHS_AGE | CANCEL_DT   | CITY     | POP   |
|-----------:|-----------:|------------:|--------:|:------|--------------:|:----------------|-------------:|:------------|:---------|:------|
|          1 |   27451596 |     2899229 |  446    | D     |           941 | 20-NOV-12       |        53.22 | 26-ABR-17   | MONCLOVA | MC    |
|          1 | 1339824066 |     4338316 |  206.45 | D+    |           679 | 05-JUN-17       |         0.7  | 27-JUN-17   | MONCLOVA | MC    |
|          1 |  353001149 |     4038911 |  499.8  | D     |           890 | 09-ENE-15       |         2.12 | 12-MAR-15   | MONCLOVA | MC    |
|          1 |  307578625 |     2684795 |  390    | B     |           909 | 20-AGO-10       |        50.21 | 26-OCT-14   | MONCLOVA | MC    |
|          1 |  361573968 |     4043068 |  550    | C     |          4892 | 12-ENE-15       |         4.18 | 18-MAY-15   | MONCLOVA | MC    |
|          1 |  310788600 |     4012341 | 1062    | C     |          3273 | 30-OCT-14       |         2.18 | 05-ENE-15   | MONCLOVA | MC    |
|          1 |  327485572 |     4022683 |  300    | A     |           188 | 21-NOV-14       |        18.16 | 26-MAY-16   | MONCLOVA | MC    |
|          1 |  377201579 |     4053180 |  625    | C     |          1162 | 21-ENE-15       |        23.09 | 24-DIC-16   | MONCLOVA | MC    |
|          1 |  307575175 |     2801853 |  640    | D     |           890 | 26-OCT-11       |        59.15 | 30-SEP-16   | MONCLOVA | MC    |
|          1 |  307576023 |     2925876 |  470    | B     |           403 | 25-ABR-13       |        18.04 | 26-OCT-14   | MONCLOVA | MC    |


Table #7
Filename: source_6.csv
Sample Rows in Markdown:
|   CANCELED |   ROW_WID |   ACCNT_LOC |   ARPU | SES   |   HOME_PASSED | CUST_SINCE_DT   |   MONTHS_AGE | CANCEL_DT   | CITY     | POP   |
|-----------:|----------:|------------:|-------:|:------|--------------:|:----------------|-------------:|:------------|:---------|:------|
|          1 | 309126228 |     4010716 |    824 | C     |           818 | 29-OCT-14       |         5.03 | 30-MAR-15   | MONCLOVA | MC    |
|          1 | 309126228 |     4010716 |    824 | C     |           818 | 29-OCT-14       |         5.09 | 01-ABR-15   | MONCLOVA | MC    |
|          1 | 309126228 |     4010716 |    824 | C     |           818 | 29-OCT-14       |         5.09 | 01-ABR-15   | MONCLOVA | MC    |
|          1 | 309126228 |     4010716 |    824 | C     |           818 | 29-OCT-14       |         5.09 | 01-ABR-15   | MONCLOVA | MC    |
|          1 | 308305583 |     4010080 |    610 | C     |           339 | 13-NOV-14       |        27.44 | 27-FEB-17   | MONCLOVA | MC    |
|          1 | 308305616 |     4010671 |    143 | C     |           790 | 11-NOV-14       |         7.47 | 26-JUN-15   | MONCLOVA | MC    |
|          1 | 309959852 |     4012104 |    393 | D     |          1153 | 08-DIC-14       |         6.58 | 26-JUN-15   | MONCLOVA | MC    |
|          1 | 309127845 |     4010712 |    526 | D     |           169 | 08-NOV-14       |         5.66 | 29-ABR-15   | FRONTERA | MC    |
|          1 | 309959178 |     4011714 |    499 | C     |           818 | 06-NOV-14       |         5.72 | 29-ABR-15   | MONCLOVA | MC    |
|          1 | 314951943 |     4014557 |    452 | C     |           767 | 07-NOV-14       |         7.6  | 26-JUN-15   | MONCLOVA | MC    |


Table #8
Filename: source_7.csv
Sample Rows in Markdown:
|   CANCELED |    ROW_WID |   ACCNT_LOC |   ARPU | SES   |   HOME_PASSED | CUST_SINCE_DT   |   MONTHS_AGE | CANCEL_DT   | CITY     | POP   |
|-----------:|-----------:|------------:|-------:|:------|--------------:|:----------------|-------------:|:------------|:---------|:------|
|          0 | 1368769675 |     4341337 | 302.04 | D     |          2376 | 23-JUN-17       |         2.44 |             | MONCLOVA | MC    |
|          0 | 1369735207 |     4341343 | 371.67 | D     |           325 | 26-JUN-17       |         2.34 |             | MONCLOVA | MC    |
|          0 | 1369735208 |     4341372 | 278.6  | D     |           489 | 24-JUN-17       |         2.41 |             | MONCLOVA | MC    |
|          0 | 1339824063 |     4338319 | 252.02 | D     |          1813 | 05-JUN-17       |         3.02 |             | MONCLOVA | MC    |
|          0 | 1339824064 |     4338323 | 438.39 | D     |          1813 | 05-JUN-17       |         3.02 |             | MONCLOVA | MC    |
|          0 | 1370037750 |     4341449 | 318.89 | D     |           387 | 26-JUN-17       |         2.34 |             | MONCLOVA | MC    |
|          0 | 1339824065 |     4338312 | 402.98 | D+    |           679 | 01-JUN-17       |         3.15 |             | MONCLOVA | MC    |
|          0 | 1368769680 |     4341340 | 384.51 | C     |          1306 | 24-JUN-17       |         2.41 |             | MONCLOVA | MC    |
|          0 | 1370037756 |     4341457 | 332.44 | D     |           876 | 27-JUN-17       |         2.31 |             | MONCLOVA | MC    |
|          0 | 1370037757 |     4341462 | 363    | D     |           536 | 06-JUL-17       |         2    |             | MONCLOVA | MC    |


Table #9
Filename: source_8.csv
Sample Rows in Markdown:
|     ROW_WID |   INTERACTIONS_NUM |
|------------:|-------------------:|
| 6.67847e+08 |                 56 |
| 6.67974e+08 |                 90 |
| 6.67976e+08 |                 30 |
| 6.67979e+08 |                 30 |
| 6.6798e+08  |                  8 |
| 6.6798e+08  |                 24 |
| 6.67981e+08 |                 94 |
| 6.67981e+08 |                 22 |
| 6.67981e+08 |                133 |
| 6.67981e+08 |                 51 |


Table #10
Filename: source_9.csv
Sample Rows in Markdown:
|     ROW_WID |   VISITS_NUM |
|------------:|-------------:|
| 3.80723e+08 |            4 |
| 3.07581e+08 |           12 |
| 1.39629e+09 |            1 |
| 3.07578e+08 |            1 |
| 1.31973e+09 |            3 |
| 3.07582e+08 |            1 |
| 1.44298e+09 |            1 |
| 3.07578e+08 |            7 |
| 3.09126e+08 |            4 |
| 1.27086e+09 |            2 |


Target Schema:
|   ARPU |
|-------:|
| 626.94 |
| 591.27 |
| 618.93 |
| 463.2  |
| 510.39 |
| 499.13 |
| 284.22 |
| 612.41 |
| 641.14 |
| 465.49 |

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
source_7.csv
source_8.csv
source_9.csv
test: test_0.csv
test_1.csv
test_2.csv
test_3.csv
test_4.csv
test_5.csv
test_6.csv
test_7.csv
test_8.csv
test_9.csv