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:
| state   | date       |       draw_sales |
|:--------|:-----------|-----------------:|
| MI      | 2014-07-16 | 649366           |
| MO      | 2014-05-10 | 650206           |
| WV      | 2011-01-12 | 258404           |
| ME      | 2012-05-19 | 170318           |
| NH      | 2010-11-27 | 224568           |
| VI      | 2011-08-13 |  15415           |
| NH      | 2014-03-29 | 223330           |
| FL      | 2010-11-06 |      4.36321e+06 |
| DE      | 2010-02-20 | 181282           |
| LA      | 2013-08-07 |      4.66556e+06 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| full_state     | state   |         pop |   year |
|:---------------|:--------|------------:|-------:|
| California     | CA      | 3.75409e+07 |   2011 |
| Texas          | TX      | 2.55906e+07 |   2011 |
| Florida        | FL      | 1.91165e+07 |   2011 |
| New York       | NY      | 1.93986e+07 |   2011 |
| Pennsylvania   | PA      | 1.27159e+07 |   2011 |
| Illinois       | IL      | 1.28202e+07 |   2011 |
| Ohio           | OH      | 1.15558e+07 |   2011 |
| Georgia        | GA      | 9.79253e+06 |   2011 |
| North Carolina | NC      | 9.64168e+06 |   2011 |
| Michigan       | MI      | 9.89848e+06 |   2011 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| state   | date       |   draw_sales |
|:--------|:-----------|-------------:|
| AR      | 2012-06-01 |       112179 |
| IA      | 2013-04-16 |       125534 |
| MT      | 2017-10-31 |        29344 |
| SD      | 2011-01-18 |        21103 |
| IA      | 2011-09-13 |       107271 |
| PA      | 2012-02-07 |       577605 |
| IA      | 2015-03-13 |        96181 |
| SD      | 2011-02-01 |        26334 |
| TX      | 2011-04-15 |      1675114 |
| NJ      | 2014-05-30 |      1055015 |


Target Schema:
| state   |   year |   draw_sales |   full_state |   pop |
|:--------|-------:|-------------:|-------------:|------:|
| AR      |      8 |            8 |            8 |     8 |
| AZ      |      8 |            8 |            8 |     8 |
| CA      |      8 |            8 |            8 |     8 |
| CO      |      8 |            8 |            8 |     8 |
| CT      |      8 |            8 |            8 |     8 |
| DC      |      8 |            8 |            8 |     8 |
| DE      |      8 |            8 |            8 |     8 |
| FL      |      6 |            6 |            6 |     6 |
| GA      |      8 |            8 |            8 |     8 |
| IA      |      8 |            8 |            8 |     8 |

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
test: test_0.csv
test_1.csv
test_2.csv