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:
|   WarID | WarShortName                       |   WarType |
|--------:|:-----------------------------------|----------:|
|    1500 | First Maori Tribal War             |         8 |
|    1501 | Shaka Zulu-Bantu War               |         8 |
|    1502 | Burma-Assam War                    |         8 |
|    1503 | Buenos Aires War                   |         8 |
|    1505 | Second Maori Tribal War            |         8 |
|    1506 | Siam-Kedah War                     |         8 |
|    1508 | China-Kashgaria War                |         8 |
|    1509 | Mexico-Yaqui Indian War            |         8 |
|    1510 | Central American Confederation War |         8 |
|    1511 | Viang Chan- Siamese War            |         8 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   WarID | WarShortName                  |   WarType |   IsIntervention |
|--------:|:------------------------------|----------:|-----------------:|
|     300 | Allied Bombardment of Algiers |         3 |                1 |
|     301 | Ottoman-Wahhabi               |         3 |                0 |
|     302 | Liberation of Chile           |         2 |                0 |
|     303 | First Bolivar Expedition      |         2 |                0 |
|     304 | Mexican Independence          |         2 |                0 |
|     305 | British-Kandyan               |         2 |                0 |
|     306 | British-Maratha               |         2 |                0 |
|     307 | Ottoman Conquest of Sudan     |         3 |                0 |
|     308 | Second Bolivar Expedition     |         2 |                0 |
|     309 | Turco-Persian                 |         3 |                0 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|   WarID | WarShortName             |   WarType |
|--------:|:-------------------------|----------:|
|       1 | Franco-Spanish War       |         1 |
|       4 | First Russo-Turkish      |         1 |
|       7 | Mexican-American         |         1 |
|      10 | Austro-Sardinian         |         1 |
|      13 | First Schleswig-Holstein |         1 |
|      16 | Roman Republic           |         1 |
|      19 | La Plata                 |         1 |
|      22 | Crimean                  |         1 |
|      25 | Anglo-Persian            |         1 |
|      28 | Italian Unification      |         1 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
|   WarID | WarShortName                     |   WarType |   IsInternational |
|--------:|:---------------------------------|----------:|------------------:|
|     726 | Taiwan Revolt                    |         5 |                 0 |
|     727 | Paraguay                         |         4 |                 0 |
|     728 | Yemeni Imamate                   |         4 |                 0 |
|     730 | Costa Rica                       |         4 |                 0 |
|     731 | Seventh Colombian "La Violencia" |         4 |                 0 |
|     732 | First Burmese                    |         5 |                 0 |
|     733 | South Moluccas                   |         5 |                 0 |
|     735 | Hukbalahap Rebellion             |         4 |                 0 |
|     737 | Bolivia                          |         4 |                 0 |
|     738 | Indonesia Darul Islam            |         4 |                 0 |


Target Schema:
|   IsIntervention |   WarID |   WarShortName |   WarType |   IsInternational |
|-----------------:|--------:|---------------:|----------:|------------------:|
|                0 |     146 |            146 |       146 |                 0 |
|                1 |      17 |             17 |        17 |                 0 |

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