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:
| Initiator              |   WarID |   PolityID |   PolityName |   StartMonth |   StartDay |   StartYear |   EndMonth |   EndDay |   EndYear |   Outcome |   Deaths |
|:-----------------------|--------:|-----------:|-------------:|-------------:|-----------:|------------:|-----------:|---------:|----------:|----------:|---------:|
| 19th Route Army        |       4 |          2 |            4 |            2 |          2 |           2 |          2 |        2 |         2 |         4 |        0 |
| Agrarian League        |       4 |          2 |            4 |            2 |          2 |           2 |          2 |        2 |         2 |         4 |        0 |
| Albania                |       4 |          2 |            4 |            2 |          0 |           2 |          2 |        2 |         2 |         4 |        0 |
| Albanians              |       4 |          2 |            4 |            2 |          0 |           2 |          2 |        0 |         2 |         4 |        4 |
| Amir Bashir & Egypt    |       4 |          0 |            4 |            2 |          2 |           2 |          2 |        2 |         2 |         4 |        4 |
| Anti-Bolsheviks        |       4 |          2 |            4 |            2 |          2 |           2 |          2 |        2 |         2 |         4 |        4 |
| Anti-Communists        |       4 |          2 |            4 |            2 |          2 |           2 |          2 |        2 |         2 |         4 |        4 |
| Anti-Imam Coalition    |       4 |          2 |            4 |            2 |          2 |           2 |          2 |        2 |         2 |         4 |        0 |
| Anti-government troops |       4 |          2 |            4 |            2 |          2 |           2 |          2 |        2 |         2 |         4 |        0 |
| Aprista Rebels         |       4 |          2 |            4 |            2 |          2 |           2 |          2 |        2 |         2 |         4 |        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