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:
|   Store | StoreType   | Assortment   |   CompetitionDistance |   CompetitionOpenSinceMonth |   CompetitionOpenSinceYear |   Promo2 | Promo2SinceWeek   | Promo2SinceYear   | PromoInterval   |
|--------:|:------------|:-------------|----------------------:|----------------------------:|---------------------------:|---------:|:------------------|:------------------|:----------------|
|       1 | c           | a            |                  1270 |                           9 |                       2008 |        0 |                   |                   |                 |
|       2 | a           | a            |                   570 |                          11 |                       2007 |        1 | 13.0              | 2010.0            | Jan,Apr,Jul,Oct |
|       3 | a           | a            |                 14130 |                          12 |                       2006 |        1 | 14.0              | 2011.0            | Jan,Apr,Jul,Oct |
|       4 | c           | c            |                   620 |                           9 |                       2009 |        0 |                   |                   |                 |
|       5 | a           | a            |                 29910 |                           4 |                       2015 |        0 |                   |                   |                 |
|       6 | a           | a            |                   310 |                          12 |                       2013 |        0 |                   |                   |                 |
|       7 | a           | c            |                 24000 |                           4 |                       2013 |        0 |                   |                   |                 |
|       8 | a           | a            |                  7520 |                          10 |                       2014 |        0 |                   |                   |                 |
|       9 | a           | c            |                  2030 |                           8 |                       2000 |        0 |                   |                   |                 |
|      10 | a           | a            |                  3160 |                           9 |                       2009 |        0 |                   |                   |                 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| Date       |   Store |   Dept |   Weekly_Sales | IsHoliday   |
|:-----------|--------:|-------:|---------------:|:------------|
| 2011-07-29 |      35 |      6 |        7074.61 | False       |
| 2010-02-26 |      41 |     16 |        3787.08 | False       |
| 2011-06-10 |       8 |     34 |       10374    | False       |
| 2011-12-23 |      42 |     23 |          34.98 | False       |
| 2012-01-20 |      19 |     80 |       20627    | False       |
| 2010-02-12 |      39 |      9 |       12093.3  | True        |
| 2011-09-09 |      29 |     82 |        8368.6  | True        |
| 2010-11-26 |      34 |     16 |        5568.35 | True        |
| 2010-12-24 |      42 |      3 |         773.56 | False       |
| 2011-04-22 |      17 |     79 |       27974.9  | False       |


Target Schema:
| StoreType   |   Store |   Dept |   Weekly_Sales |   IsHoliday |   Assortment |   CompetitionDistance |   CompetitionOpenSinceMonth |   CompetitionOpenSinceYear |   Promo2 |   Promo2SinceWeek |   Promo2SinceYear |   PromoInterval |
|:------------|--------:|-------:|---------------:|------------:|-------------:|----------------------:|----------------------------:|---------------------------:|---------:|------------------:|------------------:|----------------:|
| a           |   57226 |  57226 |          57226 |       57226 |        57226 |                 57226 |                       41417 |                      41417 |    57226 |             37972 |             37972 |           37972 |
| c           |   13598 |  13598 |          13598 |       13598 |        13598 |                 13598 |                       13598 |                      13598 |    13598 |              2297 |              2297 |            2297 |
| d           |   29176 |  29176 |          29176 |       29176 |        29176 |                 29176 |                       18186 |                      18186 |    29176 |             15786 |             15786 |           15786 |

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