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:
| Date       |   Store |   Dept |   Weekly_Sales | IsHoliday   |
|:-----------|--------:|-------:|---------------:|:------------|
| 2010-11-05 |      13 |     36 |        1057    | False       |
| 2011-01-07 |       9 |     40 |       30553.1  | False       |
| 2011-06-17 |      44 |      2 |        8810.27 | False       |
| 2011-05-06 |       4 |     24 |        8755.62 | False       |
| 2010-09-24 |       6 |     85 |        2252.41 | False       |
| 2010-09-24 |      41 |     55 |        9447.52 | False       |
| 2011-08-26 |      13 |     35 |        3310.76 | False       |
| 2012-04-27 |      10 |     36 |        6399    | False       |
| 2012-06-29 |      10 |     96 |       13649.7  | False       |
| 2012-04-27 |      12 |     56 |        2067.88 | False       |


Table #2
Filename: source_1.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 |                   |                   |                 |


Target Schema:
| StoreType   |   Store |
|:------------|--------:|
| a           |      26 |
| c           |       6 |
| d           |      13 |

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