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:
| Mouse ID   | Drug     |
|:-----------|:---------|
| f234       | Stelasyn |
| x402       | Stelasyn |
| a492       | Stelasyn |
| w540       | Stelasyn |
| v764       | Stelasyn |
| o848       | Stelasyn |
| z314       | Stelasyn |
| g989       | Stelasyn |
| m269       | Stelasyn |
| a963       | Stelasyn |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| Mouse ID   |   Timepoint |   Tumor Volume (mm3) |   Metastatic Sites |
|:-----------|------------:|---------------------:|-------------------:|
| n763       |          20 |              49.2581 |                  1 |
| q787       |          20 |              50.2299 |                  2 |
| y163       |          20 |              54.5711 |                  1 |
| g570       |          20 |              54.6433 |                  1 |
| g989       |          20 |              55.3261 |                  1 |
| s141       |          20 |              51.6216 |                  1 |
| q511       |          20 |              52.6727 |                  0 |
| s121       |          20 |              52.0051 |                  2 |
| t718       |          20 |              52.6367 |                  2 |
| k210       |          20 |              51.9976 |                  0 |


Target Schema:
| Drug      |   Timepoint |   Mean of Metastatic Sites |   Mouse ID |   Tumor Volume (mm3) |   SEM of Metastatic Sites |
|:----------|------------:|---------------------------:|-----------:|---------------------:|--------------------------:|
| Capomulin |           0 |                   0        |         25 |                   25 |                        25 |
| Capomulin |           5 |                   0.16     |         25 |                   25 |                        25 |
| Capomulin |          10 |                   0.32     |         25 |                   25 |                        25 |
| Capomulin |          15 |                   0.375    |         24 |                   24 |                        24 |
| Capomulin |          20 |                   0.8      |          5 |                    5 |                         5 |
| Ceftamin  |           0 |                   0        |         25 |                   25 |                        25 |
| Ceftamin  |           5 |                   0.380952 |         21 |                   21 |                        21 |
| Ceftamin  |          10 |                   0.6      |         20 |                   20 |                        20 |
| Ceftamin  |          15 |                   0.789474 |         19 |                   19 |                        19 |
| Infubinol |           0 |                   0        |         25 |                   25 |                        25 |

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