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:
|   WarNum | WarName                  |   WarType | CcodeA   | SideA                      | CcodeB   | SideB                    |   Intnl |   StartMonth1 | StartDay1   |   StartYear1 |   EndMonth1 |   EndDay1 |   EndYear1 | StartMonth2   | StartDay2   | StartYear2   | EndMonth2   | EndDay2   | EndYear2   | TransFrom   |   WhereFought | Initiator   |   Outcome | TransTo   | SideADeaths   | SideBDeaths   |   Version |
|---------:|:-------------------------|----------:|:---------|:---------------------------|:---------|:-------------------------|--------:|--------------:|:------------|-------------:|------------:|----------:|-----------:|:--------------|:------------|:-------------|:------------|:----------|:-----------|:------------|--------------:|:------------|----------:|:----------|:--------------|:--------------|----------:|
|      751 | First Laotian            |         4 |          |                            | 816.0    | Vietnam, Democratic Rep. |       1 |             5 | 1.0         |         1961 |           6 |        15 |       1962 |               |             |              |             |           |            |             |             7 | Pathet Lao  |         3 |           |               |               |       4.1 |
|      751 | First Laotian            |         4 | 812.0    | Laos                       |          | Pathet Lao               |       1 |            10 | 15.0        |         1960 |           7 |        15 |       1962 |               |             |              |             |           |            |             |             7 | Pathet Lao  |         3 |           | 4000          | 1000          |       4.1 |
|      752 | First Iraqi Kurd         |         5 | 645.0    | Iraq                       |          | Kurds                    |       0 |             9 | 11.0        |         1961 |          11 |        22 |       1963 |               |             |              |             |           |            |             |             6 | Kurds       |         6 |           | 500           | 2000          |       4.1 |
|      753 | Algerian Revolutionaries |         4 | 615.0    | Algeria                    |          | ALN                      |       0 |             7 | 28.0        |         1962 |           1 |        15 |       1963 |               |             |              |             |           |            |             |             6 | ALN         |         2 |           | 800           | 700           |       4.1 |
|      755 | North Yemen              |         4 | 651.0    | Egypt/United Arab Republic |          |                          |       1 |            12 | 15.0        |         1962 |          10 |        16 |       1967 |               |             |              |             |           |            |             |             6 | Royalists   |         1 |           | 10000         |               |       4.1 |
|      755 | North Yemen              |         4 | 678.0    | Yemen Arab Republic        |          | Royalists                |       1 |            11 | 15.0        |         1962 |           9 |         3 |       1969 |               |             |              |             |           |            |             |             6 | Royalists   |         1 |           |               |               |       4.1 |
|      756 | Second Laotian Phase 1   |         4 | 2.0      | United States of America   |          |                          |       1 |             5 | 19.0        |         1964 |           1 |        12 |       1968 |               |             |              |             |           |            |             |             7 | Pathet Lao  |         4 | 170.0     | 200           |               |       4.1 |
|      756 | Second Laotian Phase 1   |         4 | 812.0    | Laos                       |          | Pathet Lao               |       1 |             3 | 19.0        |         1963 |           1 |        12 |       1968 |               |             |              |             |           |            |             |             7 | Pathet Lao  |         4 | 170.0     | 11250         | 7250          |       4.1 |
|      756 | Second Laotian Phase 1   |         4 |          |                            | 816.0    | Vietnam, Democratic Rep. |       1 |             3 | 19.0        |         1963 |           1 |        12 |       1968 |               |             |              |             |           |            |             |             7 | Pathet Lao  |         4 | 170.0     |               | 2250          |       4.1 |
|      757 | First Ogaden             |         5 |          |                            | 520.0    | Somalia                  |       1 |            11 |             |         1963 |           3 |        30 |       1964 |               |             |              |             |           |            |             |             4 | Ogaden      |         1 |           |               |               |       4.1 |


Target Schema:
|   Outcome |   WarID |   PolityID |   PolityName |   StartMonth |   StartDay |   StartYear |   EndMonth |   EndDay |   EndYear |   Initiator |   Deaths |
|----------:|--------:|-----------:|-------------:|-------------:|-----------:|------------:|-----------:|---------:|----------:|------------:|---------:|
|         1 |     568 |        276 |          522 |          278 |        246 |         290 |        276 |      252 |       288 |         540 |      296 |
|         2 |     232 |         96 |          216 |          116 |        108 |         118 |        116 |      114 |       116 |         232 |      134 |
|         3 |       8 |          4 |            8 |            4 |          2 |           4 |          4 |        4 |         4 |           8 |        4 |
|         4 |      56 |         24 |           48 |           28 |         26 |          28 |         28 |       28 |        28 |          56 |       26 |
|         6 |      12 |          6 |           12 |            6 |          6 |           6 |          6 |        6 |         6 |          12 |       10 |
|         7 |       8 |          4 |            8 |            4 |          2 |           4 |          4 |        2 |         4 |           8 |        4 |

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