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:
| State   | State Name   |   Year | Month    | Indicator                                  |   Data Value |   Predicted Value |   Percent Complete |   Percent Pending Investigation | Footnote   |
|:--------|:-------------|-------:|:---------|:-------------------------------------------|-------------:|------------------:|-------------------:|--------------------------------:|:-----------|
| NM      | New Mexico   |   2015 | December | Synthetic opioids, excl. methadone (T40.4) |           41 |                43 |                100 |                      0.0937756  |            |
| NM      | New Mexico   |   2016 | December | Synthetic opioids, excl. methadone (T40.4) |           78 |                80 |                100 |                      0.0506529  |            |
| NV      | Nevada       |   2015 | December | Cocaine (T40.5)                            |           45 |                47 |                100 |                      0.00422887 |            |
| NV      | Nevada       |   2016 | December | Cocaine (T40.5)                            |           44 |                46 |                100 |                      0          |            |
| NV      | Nevada       |   2015 | December | Heroin (T40.1)                             |           91 |                92 |                100 |                      0.00422887 |            |
| NV      | Nevada       |   2016 | December | Heroin (T40.1)                             |           92 |                93 |                100 |                      0          |            |
| NV      | Nevada       |   2015 | December | Methadone (T40.3)                          |           59 |                60 |                100 |                      0.00422887 |            |
| NV      | Nevada       |   2016 | December | Methadone (T40.3)                          |           54 |                54 |                100 |                      0          |            |
| NV      | Nevada       |   2015 | December | Natural & semi-synthetic opioids (T40.2)   |          271 |               273 |                100 |                      0.00422887 |            |
| NV      | Nevada       |   2016 | December | Natural & semi-synthetic opioids (T40.2)   |          240 |               242 |                100 |                      0          |            |


Target Schema:
| State Name   |   Year | Month    | Cocaine (T40.5)   | Heroin (T40.1)   | Methadone (T40.3)   | Natural & semi-synthetic opioids (T40.2)   |   Number of Deaths |   Number of Drug Overdose Deaths | Opioids (T40.0-T40.4,T40.6)   | Psychostimulants with abuse potential (T43.6)   | Synthetic opioids, excl. methadone (T40.4)   |
|:-------------|-------:|:---------|:------------------|:-----------------|:--------------------|:-------------------------------------------|-------------------:|---------------------------------:|:------------------------------|:------------------------------------------------|:---------------------------------------------|
| Alabama      |   2015 | December |                   |                  |                     |                                            |              50870 |                              720 |                               |                                                 |                                              |
| Alabama      |   2016 | December |                   |                  |                     |                                            |              51431 |                              740 |                               |                                                 |                                              |
| Alaska       |   2015 | December |                   |                  |                     |                                            |               4193 |                              121 |                               |                                                 |                                              |
| Alaska       |   2016 | December |                   |                  |                     |                                            |               4355 |                              129 |                               |                                                 |                                              |
| Arizona      |   2015 | December |                   |                  |                     |                                            |              54853 |                             1267 |                               |                                                 |                                              |
| Arizona      |   2016 | December |                   |                  |                     |                                            |              57215 |                             1393 |                               |                                                 |                                              |
| Arkansas     |   2015 | December |                   |                  |                     |                                            |              30986 |                              381 |                               |                                                 |                                              |
| Arkansas     |   2016 | December |                   |                  |                     |                                            |              31028 |                              386 |                               |                                                 |                                              |
| California   |   2015 | December |                   |                  |                     |                                            |             260172 |                             4762 |                               |                                                 |                                              |
| California   |   2016 | December |                   |                  |                     |                                            |             263199 |                             4755 |                               |                                                 |                                              |

Return only the final code in markdown codeblock format, without any additional text or explanation. 



target: target.csv
train: source_0.csv
test: test_0.csv