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:
|        a | b   | c              |        d |
|---------:|:----|:---------------|---------:|
| 0.683013 | CAD | 7/1/2005 0:00  | 0.68106  |
| 0.682082 | CAD | 7/2/2005 0:00  | 0.683201 |
| 0.68157  | CAD | 7/3/2005 0:00  | 0.678702 |
| 0.68157  | CAD | 7/4/2005 0:00  | 0.68451  |
| 0.68306  | CAD | 7/5/2005 0:00  | 0.681524 |
| 0.683013 | CAD | 7/6/2005 0:00  | 0.686672 |
| 0.683948 | CAD | 7/7/2005 0:00  | 0.682082 |
| 0.683854 | CAD | 7/8/2005 0:00  | 0.684744 |
| 0.682221 | CAD | 7/9/2005 0:00  | 0.677874 |
| 0.681292 | CAD | 7/10/2005 0:00 | 0.685495 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|       a | b   | c              |       d |
|--------:|:----|:---------------|--------:|
| 0.00158 | VEB | 7/1/2005 0:00  | 0.00158 |
| 0.00158 | VEB | 7/2/2005 0:00  | 0.00158 |
| 0.00158 | VEB | 7/3/2005 0:00  | 0.00158 |
| 0.00157 | VEB | 7/4/2005 0:00  | 0.00157 |
| 0.00157 | VEB | 7/5/2005 0:00  | 0.00157 |
| 0.00157 | VEB | 7/6/2005 0:00  | 0.00157 |
| 0.00157 | VEB | 7/7/2005 0:00  | 0.00157 |
| 0.00157 | VEB | 7/8/2005 0:00  | 0.00157 |
| 0.00157 | VEB | 7/9/2005 0:00  | 0.00157 |
| 0.00157 | VEB | 7/10/2005 0:00 | 0.00157 |


Table #3
Filename: source_10.csv
Sample Rows in Markdown:
|        a | b   | c              |        d |
|---------:|:----|:---------------|---------:|
| 0.120801 | CNY | 7/1/2005 0:00  | 0.120796 |
| 0.120801 | CNY | 7/2/2005 0:00  | 0.120811 |
| 0.120801 | CNY | 7/3/2005 0:00  | 0.120789 |
| 0.120798 | CNY | 7/4/2005 0:00  | 0.120799 |
| 0.120796 | CNY | 7/5/2005 0:00  | 0.12079  |
| 0.120796 | CNY | 7/6/2005 0:00  | 0.120802 |
| 0.120796 | CNY | 7/7/2005 0:00  | 0.120796 |
| 0.120796 | CNY | 7/8/2005 0:00  | 0.120804 |
| 0.120798 | CNY | 7/9/2005 0:00  | 0.120793 |
| 0.120798 | CNY | 7/10/2005 0:00 | 0.120804 |


Table #4
Filename: source_11.csv
Sample Rows in Markdown:
|        a | b   | c              |        d |
|---------:|:----|:---------------|---------:|
| 0.527232 | DEM | 7/1/2005 0:00  | 0.526981 |
| 0.52843  | DEM | 7/2/2005 0:00  | 0.528485 |
| 0.532028 | DEM | 7/3/2005 0:00  | 0.531858 |
| 0.531604 | DEM | 7/4/2005 0:00  | 0.531887 |
| 0.526926 | DEM | 7/5/2005 0:00  | 0.526759 |
| 0.526122 | DEM | 7/6/2005 0:00  | 0.526399 |
| 0.526676 | DEM | 7/7/2005 0:00  | 0.526593 |
| 0.527287 | DEM | 7/8/2005 0:00  | 0.52751  |
| 0.527232 | DEM | 7/9/2005 0:00  | 0.52712  |
| 0.523095 | DEM | 7/10/2005 0:00 | 0.523314 |


Table #5
Filename: source_12.csv
Sample Rows in Markdown:
|       a | b   | c              |       d |
|--------:|:----|:---------------|--------:|
| 1.61734 | GBP | 7/1/2005 0:00  | 1.61734 |
| 1.6218  | GBP | 7/2/2005 0:00  | 1.62285 |
| 1.62443 | GBP | 7/3/2005 0:00  | 1.62259 |
| 1.62259 | GBP | 7/4/2005 0:00  | 1.62364 |
| 1.61681 | GBP | 7/5/2005 0:00  | 1.61655 |
| 1.61838 | GBP | 7/6/2005 0:00  | 1.61996 |
| 1.61891 | GBP | 7/7/2005 0:00  | 1.61838 |
| 1.62048 | GBP | 7/8/2005 0:00  | 1.62259 |
| 1.62364 | GBP | 7/9/2005 0:00  | 1.62259 |
| 1.61525 | GBP | 7/10/2005 0:00 | 1.61577 |


Table #6
Filename: source_13.csv
Sample Rows in Markdown:
|        a | b   | c              |        d |
|---------:|:----|:---------------|---------:|
| 0.106678 | MXN | 7/1/2005 0:00  | 0.106564 |
| 0.106441 | MXN | 7/2/2005 0:00  | 0.106475 |
| 0.106895 | MXN | 7/3/2005 0:00  | 0.106895 |
| 0.106998 | MXN | 7/4/2005 0:00  | 0.107102 |
| 0.107124 | MXN | 7/5/2005 0:00  | 0.107102 |
| 0.107124 | MXN | 7/6/2005 0:00  | 0.107216 |
| 0.107124 | MXN | 7/7/2005 0:00  | 0.107022 |
| 0.107239 | MXN | 7/8/2005 0:00  | 0.107262 |
| 0.107068 | MXN | 7/9/2005 0:00  | 0.107068 |
| 0.107446 | MXN | 7/10/2005 0:00 | 0.10754  |


Table #7
Filename: source_14.csv
Sample Rows in Markdown:
|        a | b   | c              |        d |
|---------:|:----|:---------------|---------:|
| 0.516022 | BRL | 7/1/2005 0:00  | 0.51496  |
| 0.51709  | BRL | 7/2/2005 0:00  | 0.517331 |
| 0.516556 | BRL | 7/3/2005 0:00  | 0.514403 |
| 0.518269 | BRL | 7/4/2005 0:00  | 0.519481 |
| 0.517625 | BRL | 7/5/2005 0:00  | 0.516262 |
| 0.517331 | BRL | 7/6/2005 0:00  | 0.519481 |
| 0.517331 | BRL | 7/7/2005 0:00  | 0.516022 |
| 0.517331 | BRL | 7/8/2005 0:00  | 0.520061 |
| 0.517331 | BRL | 7/9/2005 0:00  | 0.51709  |
| 0.518403 | BRL | 7/10/2005 0:00 | 0.52086  |


Table #8
Filename: source_15.csv
Sample Rows in Markdown:
|        a | b   | c              |        d |
|---------:|:----|:---------------|---------:|
| 0.157206 | FRF | 7/1/2005 0:00  | 0.157201 |
| 0.15756  | FRF | 7/2/2005 0:00  | 0.157567 |
| 0.158627 | FRF | 7/3/2005 0:00  | 0.158627 |
| 0.158504 | FRF | 7/4/2005 0:00  | 0.158529 |
| 0.157099 | FRF | 7/5/2005 0:00  | 0.157089 |
| 0.156873 | FRF | 7/6/2005 0:00  | 0.156882 |
| 0.15704  | FRF | 7/7/2005 0:00  | 0.157033 |
| 0.15722  | FRF | 7/8/2005 0:00  | 0.15722  |
| 0.157206 | FRF | 7/9/2005 0:00  | 0.157201 |
| 0.15597  | FRF | 7/10/2005 0:00 | 0.155984 |


Table #9
Filename: source_2.csv
Sample Rows in Markdown:
|   cur-id | symbol   | name                |
|---------:|:---------|:--------------------|
|        1 | AFA      | Afghani             |
|        2 | DZD      | Algerian Dinar      |
|        3 | ARS      | Argentine Peso      |
|        4 | AMD      | Armenian Dram       |
|        5 | AWG      | Aruban Guilder      |
|        6 | AUD      | Australian Dollar   |
|        7 | AZM      | Azerbaijanian Manat |
|        8 | BSD      | Bahamian Dollar     |
|        9 | BHD      | Bahraini Dinar      |
|       10 | THB      | Baht                |


Table #10
Filename: source_3.csv
Sample Rows in Markdown:
|   a | b   | c              |   d |
|----:|:----|:---------------|----:|
|   1 | USD | 7/1/2005 0:00  |   1 |
|   1 | USD | 7/2/2005 0:00  |   1 |
|   1 | USD | 7/3/2005 0:00  |   1 |
|   1 | USD | 7/4/2005 0:00  |   1 |
|   1 | USD | 7/5/2005 0:00  |   1 |
|   1 | USD | 7/6/2005 0:00  |   1 |
|   1 | USD | 7/7/2005 0:00  |   1 |
|   1 | USD | 7/8/2005 0:00  |   1 |
|   1 | USD | 7/9/2005 0:00  |   1 |
|   1 | USD | 7/10/2005 0:00 |   1 |


Table #11
Filename: source_4.csv
Sample Rows in Markdown:
|   date-id | date            |   2 | 3         | 4         | 5        |   6 |   7 |   8 | 9        | 10        | 11       |   12 |   13 |   14 |   15 |   16 |   17 |   18 |
|----------:|:----------------|----:|:----------|:----------|:---------|----:|----:|----:|:---------|:----------|:---------|-----:|-----:|-----:|-----:|-----:|-----:|-----:|
|  20131121 | 11/21/2013 0:00 |   5 | Thursday  | Jueves    | Jeudi    |  21 | 325 |  47 | November | Noviembre | Novembre |   11 |    4 | 2013 |    2 |    2 | 2013 |    1 |
|  20070812 | 8/12/2007 0:00  |   1 | Sunday    | Domingo   | Dimanche |  12 | 224 |  33 | August   | Agosto    | Août     |    8 |    3 | 2007 |    2 |    1 | 2008 |    1 |
|  20130810 | 8/10/2013 0:00  |   7 | Saturday  | Sábado    | Samedi   |  10 | 222 |  32 | August   | Agosto    | Août     |    8 |    3 | 2013 |    2 |    1 | 2013 |    1 |
|  20061123 | 11/23/2006 0:00 |   5 | Thursday  | Jueves    | Jeudi    |  23 | 327 |  47 | November | Noviembre | Novembre |   11 |    4 | 2006 |    2 |    2 | 2007 |    1 |
|  20111204 | 12/4/2011 0:00  |   1 | Sunday    | Domingo   | Dimanche |   4 | 338 |  50 | December | Diciembre | Décembre |   12 |    4 | 2011 |    2 |    2 | 2011 |    1 |
|  20050222 | 2/22/2005 0:00  |   3 | Tuesday   | Martes    | Mardi    |  22 |  53 |   9 | February | Febrero   | Février  |    2 |    1 | 2005 |    1 |    3 | 2005 |    2 |
|  20050716 | 7/16/2005 0:00  |   7 | Saturday  | Sábado    | Samedi   |  16 | 197 |  29 | July     | Julio     | Juillet  |    7 |    3 | 2005 |    2 |    1 | 2006 |    1 |
|  20121124 | 11/24/2012 0:00 |   7 | Saturday  | Sábado    | Samedi   |  24 | 329 |  47 | November | Noviembre | Novembre |   11 |    4 | 2012 |    2 |    2 | 2012 |    1 |
|  20130102 | 1/2/2013 0:00   |   4 | Wednesday | Miércoles | Mercredi |   2 |   2 |   1 | January  | Enero     | Janvier  |    1 |    1 | 2013 |    1 |    3 | 2012 |    2 |
|  20110324 | 3/24/2011 0:00  |   5 | Thursday  | Jueves    | Jeudi    |  24 |  83 |  13 | March    | Marzo     | Mars     |    3 |    1 | 2011 |    1 |    3 | 2010 |    2 |


Table #12
Filename: source_5.csv
Sample Rows in Markdown:
|        a | b   | c              |        d |
|---------:|:----|:---------------|---------:|
| 0.645536 | AUD | 7/1/2005 0:00  | 0.645161 |
| 0.642715 | AUD | 7/2/2005 0:00  | 0.642756 |
| 0.641355 | AUD | 7/3/2005 0:00  | 0.641149 |
| 0.639182 | AUD | 7/4/2005 0:00  | 0.639632 |
| 0.638284 | AUD | 7/5/2005 0:00  | 0.638162 |
| 0.639304 | AUD | 7/6/2005 0:00  | 0.63955  |
| 0.639182 | AUD | 7/7/2005 0:00  | 0.638896 |
| 0.637796 | AUD | 7/8/2005 0:00  | 0.637836 |
| 0.63589  | AUD | 7/9/2005 0:00  | 0.635566 |
| 0.632511 | AUD | 7/10/2005 0:00 | 0.632511 |


Table #13
Filename: source_6.csv
Sample Rows in Markdown:
|        a | b   | c              |        d |
|---------:|:----|:---------------|---------:|
| 0.266617 | SAR | 7/1/2005 0:00  | 0.266071 |
| 0.266617 | SAR | 7/2/2005 0:00  | 0.266617 |
| 0.266631 | SAR | 7/3/2005 0:00  | 0.26617  |
| 0.266724 | SAR | 7/4/2005 0:00  | 0.267265 |
| 0.266617 | SAR | 7/5/2005 0:00  | 0.265915 |
| 0.266617 | SAR | 7/6/2005 0:00  | 0.266667 |
| 0.266603 | SAR | 7/7/2005 0:00  | 0.266198 |
| 0.266617 | SAR | 7/8/2005 0:00  | 0.267308 |
| 0.266617 | SAR | 7/9/2005 0:00  | 0.266276 |
| 0.266617 | SAR | 7/10/2005 0:00 | 0.266652 |


Table #14
Filename: source_7.csv
Sample Rows in Markdown:
|       a | b   | c              |       d |
|--------:|:----|:---------------|--------:|
| 0.00953 | JPY | 7/1/2005 0:00  | 0.00953 |
| 0.00946 | JPY | 7/2/2005 0:00  | 0.00946 |
| 0.00948 | JPY | 7/3/2005 0:00  | 0.00947 |
| 0.00945 | JPY | 7/4/2005 0:00  | 0.00946 |
| 0.00942 | JPY | 7/5/2005 0:00  | 0.00942 |
| 0.0094  | JPY | 7/6/2005 0:00  | 0.0094  |
| 0.0094  | JPY | 7/7/2005 0:00  | 0.00939 |
| 0.00946 | JPY | 7/8/2005 0:00  | 0.00946 |
| 0.00957 | JPY | 7/9/2005 0:00  | 0.00957 |
| 0.00956 | JPY | 7/10/2005 0:00 | 0.00956 |


Table #15
Filename: source_8.csv
Sample Rows in Markdown:
|   a | b   | c              |        d |
|----:|:----|:---------------|---------:|
|   1 | ARS | 7/1/2005 0:00  | 0.9998   |
|   1 | ARS | 7/2/2005 0:00  | 1.0009   |
|   1 | ARS | 7/3/2005 0:00  | 0.9996   |
|   1 | ARS | 7/4/2005 0:00  | 1        |
|   1 | ARS | 7/5/2005 0:00  | 0.9996   |
|   1 | ARS | 7/6/2005 0:00  | 1.0005   |
|   1 | ARS | 7/7/2005 0:00  | 0.9995   |
|   1 | ARS | 7/8/2005 0:00  | 1.0002   |
|   1 | ARS | 7/9/2005 0:00  | 0.999201 |
|   1 | ARS | 7/10/2005 0:00 | 1.0002   |


Table #16
Filename: source_9.csv
Sample Rows in Markdown:
|       a | b   | c              |       d |
|--------:|:----|:---------------|--------:|
| 1.03125 | EUR | 7/1/2005 0:00  | 1.03061 |
| 1.03348 | EUR | 7/2/2005 0:00  | 1.03413 |
| 1.04058 | EUR | 7/3/2005 0:00  | 1.04004 |
| 1.03983 | EUR | 7/4/2005 0:00  | 1.03983 |
| 1.0305  | EUR | 7/5/2005 0:00  | 1.02976 |
| 1.02902 | EUR | 7/6/2005 0:00  | 1.02934 |
| 1.03008 | EUR | 7/7/2005 0:00  | 1.02923 |
| 1.03125 | EUR | 7/8/2005 0:00  | 1.03199 |
| 1.03125 | EUR | 7/9/2005 0:00  | 1.03029 |
| 1.02312 | EUR | 7/10/2005 0:00 | 1.02354 |


Target Schema:
|       r1 | symbol   | date          |       r2 |   cur-id | name                 |   date-id |   2 | 3        | 4      | 5      |   6 |   7 |   8 | 9    | 10    | 11      |   12 |   13 |   14 |   15 |   16 |   17 |   18 |
|---------:|:---------|:--------------|---------:|---------:|:---------------------|----------:|----:|:---------|:-------|:-------|----:|----:|----:|:-----|:------|:--------|-----:|-----:|-----:|-----:|-----:|-----:|-----:|
| 0.00946  | JPY      | 7/2/2005 0:00 | 0.00946  |      102 | Yen                  |  20050702 |   7 | Saturday | Sábado | Samedi |   2 | 183 |  27 | July | Julio | Juillet |    7 |    3 | 2005 |    2 |    1 | 2006 |    1 |
| 0.120801 | CNY      | 7/2/2005 0:00 | 0.120811 |      103 | Yuan Renminbi        |  20050702 |   7 | Saturday | Sábado | Samedi |   2 | 183 |  27 | July | Julio | Juillet |    7 |    3 | 2005 |    2 |    1 | 2006 |    1 |
| 0.106441 | MXN      | 7/2/2005 0:00 | 0.106475 |       61 | Mexican Peso         |  20050702 |   7 | Saturday | Sábado | Samedi |   2 | 183 |  27 | July | Julio | Juillet |    7 |    3 | 2005 |    2 |    1 | 2006 |    1 |
| 0.642715 | AUD      | 7/2/2005 0:00 | 0.642756 |        6 | Australian Dollar    |  20050702 |   7 | Saturday | Sábado | Samedi |   2 | 183 |  27 | July | Julio | Juillet |    7 |    3 | 2005 |    2 |    1 | 2006 |    1 |
| 1        | USD      | 7/2/2005 0:00 | 1        |      100 | US Dollar            |  20050702 |   7 | Saturday | Sábado | Samedi |   2 | 183 |  27 | July | Julio | Juillet |    7 |    3 | 2005 |    2 |    1 | 2006 |    1 |
| 0.51709  | BRL      | 7/2/2005 0:00 | 0.517331 |       16 | Brazilian Real       |  20050702 |   7 | Saturday | Sábado | Samedi |   2 | 183 |  27 | July | Julio | Juillet |    7 |    3 | 2005 |    2 |    1 | 2006 |    1 |
| 0.682082 | CAD      | 7/2/2005 0:00 | 0.683201 |       19 | Canadian Dollar      |  20050702 |   7 | Saturday | Sábado | Samedi |   2 | 183 |  27 | July | Julio | Juillet |    7 |    3 | 2005 |    2 |    1 | 2006 |    1 |
| 1.6218   | GBP      | 7/2/2005 0:00 | 1.62285  |       98 | United Kingdom Pound |  20050702 |   7 | Saturday | Sábado | Samedi |   2 | 183 |  27 | July | Julio | Juillet |    7 |    3 | 2005 |    2 |    1 | 2006 |    1 |
| 0.00158  | VEB      | 7/2/2005 0:00 | 0.00158  |       14 | Bolivar              |  20050702 |   7 | Saturday | Sábado | Samedi |   2 | 183 |  27 | July | Julio | Juillet |    7 |    3 | 2005 |    2 |    1 | 2006 |    1 |
| 0.15756  | FRF      | 7/2/2005 0:00 | 0.157567 |       39 | French Franc         |  20050702 |   7 | Saturday | Sábado | Samedi |   2 | 183 |  27 | July | Julio | Juillet |    7 |    3 | 2005 |    2 |    1 | 2006 |    1 |

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_10.csv
source_11.csv
source_12.csv
source_13.csv
source_14.csv
source_15.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_10.csv
test_11.csv
test_12.csv
test_13.csv
test_14.csv
test_15.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