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:
| state   |   statefp |   countyfp | county_name     |   fips_code | winning_party   | State   | Area_name           |   Civilian_labor_force_2012 |   Employed_2012 |   Unemployed_2012 |   Unemployment_rate_2012 |
|:--------|----------:|-----------:|:----------------|------------:|:----------------|:--------|:--------------------|----------------------------:|----------------:|------------------:|-------------------------:|
| AL      |         1 |          1 | Autauga County  |        1001 | Republican      | AL      | Autauga County, AL  |                       25740 |           23961 |              1779 |                     0.06 |
| AL      |         1 |          3 | Baldwin County  |        1003 | Republican      | AL      | Baldwin County, AL  |                       84414 |           78065 |              6349 |                     0.07 |
| AL      |         1 |          5 | Barbour County  |        1005 | Democrat        | AL      | Barbour County, AL  |                        9362 |            8283 |              1079 |                     0.11 |
| AL      |         1 |          7 | Bibb County     |        1007 | Republican      | AL      | Bibb County, AL     |                        8798 |            8047 |               751 |                     0.08 |
| AL      |         1 |          9 | Blount County   |        1009 | Republican      | AL      | Blount County, AL   |                       24960 |           23244 |              1716 |                     0.06 |
| AL      |         1 |         11 | Bullock County  |        1011 | Democrat        | AL      | Bullock County, AL  |                        4736 |            4245 |               491 |                     0.1  |
| AL      |         1 |         13 | Butler County   |        1013 | Republican      | AL      | Butler County, AL   |                        9088 |            8039 |              1049 |                     0.11 |
| AL      |         1 |         15 | Calhoun County  |        1015 | Republican      | AL      | Calhoun County, AL  |                       49649 |           45252 |              4397 |                     0.08 |
| AL      |         1 |         17 | Chambers County |        1017 | Republican      | AL      | Chambers County, AL |                       15140 |           13646 |              1494 |                     0.09 |
| AL      |         1 |         19 | Cherokee County |        1019 | Republican      | AL      | Cherokee County, AL |                       11268 |           10363 |               905 |                     0.08 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   naics |   fips_code |   unions_count |
|--------:|------------:|---------------:|
|  813930 |        1001 |              5 |
|  813930 |        1003 |              1 |
|  813930 |        1009 |              2 |
|  813930 |        1013 |              1 |
|  813930 |        1015 |              7 |
|  813930 |        1019 |              1 |
|  813930 |        1021 |              1 |
|  813930 |        1023 |              4 |
|  813930 |        1025 |              2 |
|  813930 |        1033 |             14 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
| state   |   fips_code | county          |   inactivity_count |   inactivity% |
|:--------|------------:|:----------------|-------------------:|--------------:|
| Alabama |        1001 | Autauga County  |              11310 |         28.7  |
| Alabama |        1003 | Baldwin County  |              36100 |         25.2  |
| Alabama |        1005 | Barbour County  |               6829 |         32.9  |
| Alabama |        1007 | Bibb County     |               5730 |         33.2  |
| Alabama |        1009 | Blount County   |              12130 |         28.5  |
| Alabama |        1011 | Bullock County  |               2719 |         33.1  |
| Alabama |        1013 | Butler County   |               5271 |         34.4  |
| Alabama |        1015 | Calhoun County  |              29470 |         33.6  |
| Alabama |        1017 | Chambers County |               9018 |         34.79 |
| Alabama |        1019 | Cherokee County |               6225 |         31    |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
| state   |   fips_code |   ansi_code | county_name     |   population |   housing_units |   area_land_mt |   area_water_mt |   area_land_mi |   area_water_mi |   latitude |   logitude |
|:--------|------------:|------------:|:----------------|-------------:|----------------:|---------------:|----------------:|---------------:|----------------:|-----------:|-----------:|
| AL      |        1001 |      161526 | Autauga County  |        54571 |           22135 |     1539582278 |        25775735 |         594.43 |            9.95 |      32.53 |     -86.64 |
| AL      |        1003 |      161527 | Baldwin County  |       182265 |          104061 |     4117521611 |      1133190229 |        1589.78 |          437.52 |      30.65 |     -87.74 |
| AL      |        1005 |      161528 | Barbour County  |        27457 |           11829 |     2291818968 |        50864716 |         884.87 |           19.63 |      31.87 |     -85.4  |
| AL      |        1007 |      161529 | Bibb County     |        22915 |            8981 |     1612480789 |         9289057 |         622.58 |            3.58 |      33.01 |     -87.12 |
| AL      |        1009 |      161530 | Blount County   |        57322 |           23887 |     1669961855 |        15157440 |         644.77 |            5.85 |      33.97 |     -86.56 |
| AL      |        1011 |      161531 | Bullock County  |        10914 |            4493 |     1613056905 |         6056528 |         622.8  |            2.33 |      32.1  |     -85.71 |
| AL      |        1013 |      161532 | Butler County   |        20947 |            9964 |     2011976894 |         2726814 |         776.82 |            1.05 |      31.75 |     -86.68 |
| AL      |        1015 |      161533 | Calhoun County  |       118572 |           53289 |     1569189995 |        16624267 |         605.86 |            6.41 |      33.77 |     -85.82 |
| AL      |        1017 |      161534 | Chambers County |        34215 |           17004 |     1545009282 |        17048142 |         596.53 |            6.58 |      32.91 |     -85.39 |
| AL      |        1019 |      161535 | Cherokee County |        25989 |           16267 |     1434075952 |       119858898 |         553.7  |           46.27 |      34.06 |     -85.65 |


Table #5
Filename: source_4.csv
Sample Rows in Markdown:
| state   |   fips_code | county               |   diabetes_count |   diabetes% |
|:--------|------------:|:---------------------|-----------------:|------------:|
| Montana |       30023 | Deer Lodge County    |              633 |        8.6  |
| Montana |       30025 | Fallon County        |              174 |        7.8  |
| Montana |       30027 | Fergus County        |              782 |        8.69 |
| Montana |       30029 | Flathead County      |             5081 |        7.4  |
| Montana |       30031 | Gallatin County      |             2891 |        4.2  |
| Montana |       30033 | Garfield County      |               72 |        7.6  |
| Montana |       30035 | Glacier County       |             1140 |       12.7  |
| Montana |       30037 | Golden Valley County |               63 |        9.69 |
| Montana |       30039 | Granite County       |              229 |        8.9  |
| Montana |       30041 | Hill County          |             1120 |        9.69 |


Table #6
Filename: source_5.csv
Sample Rows in Markdown:
| county_name         |   fips_code |   drug_deaths |
|:--------------------|------------:|--------------:|
| Autauga County, AL  |        1001 |            22 |
| Baldwin County, AL  |        1003 |            34 |
| Barbour County, AL  |        1005 |            22 |
| Bibb County, AL     |        1007 |            22 |
| Blount County, AL   |        1009 |            18 |
| Bullock County, AL  |        1011 |            22 |
| Butler County, AL   |        1013 |            22 |
| Calhoun County, AL  |        1015 |            22 |
| Chambers County, AL |        1017 |            22 |
| Cherokee County, AL |        1019 |            22 |


Target Schema:
| state_x   |   statefp |   countyfp | county_name_x   |   fips_code | winning_party   | State   | Area_name           |   Civilian_labor_force_2012 |   Employed_2012 |   Unemployed_2012 |   Unemployment_rate_2012 | state_y   |   ansi_code | county_name_y   |   population |   housing_units |   area_land_mt |   area_water_mt |   area_land_mi |   area_water_mi |   latitude |   logitude |   naics |   unions_count | county_x        |   diabetes_count |   diabetes% | county_y        |   inactivity_count |   inactivity% | county_name         |   drug_deaths |
|:----------|----------:|-----------:|:----------------|------------:|:----------------|:--------|:--------------------|----------------------------:|----------------:|------------------:|-------------------------:|:----------|------------:|:----------------|-------------:|----------------:|---------------:|----------------:|---------------:|----------------:|-----------:|-----------:|--------:|---------------:|:----------------|-----------------:|------------:|:----------------|-------------------:|--------------:|:--------------------|--------------:|
| AL        |         1 |          1 | Autauga County  |        1001 | Republican      | AL      | Autauga County, AL  |                       25740 |           23961 |              1779 |                     0.06 | AL        |      161526 | Autauga County  |        54571 |           22135 |     1539582278 |        25775735 |         594.43 |            9.95 |      32.53 |     -86.64 |  813930 |              5 | Autauga County  |             4724 |       12    | Autauga County  |              11310 |         28.7  | Autauga County, AL  |            22 |
| AL        |         1 |          3 | Baldwin County  |        1003 | Republican      | AL      | Baldwin County, AL  |                       84414 |           78065 |              6349 |                     0.07 | AL        |      161527 | Baldwin County  |       182265 |          104061 |     4117521611 |      1133190229 |        1589.78 |          437.52 |      30.65 |     -87.74 |  813930 |              1 | Baldwin County  |            15437 |       10.8  | Baldwin County  |              36100 |         25.2  | Baldwin County, AL  |            34 |
| AL        |         1 |          9 | Blount County   |        1009 | Republican      | AL      | Blount County, AL   |                       24960 |           23244 |              1716 |                     0.06 | AL        |      161530 | Blount County   |        57322 |           23887 |     1669961855 |        15157440 |         644.77 |            5.85 |      33.97 |     -86.56 |  813930 |              2 | Blount County   |             5869 |       13.8  | Blount County   |              12130 |         28.5  | Blount County, AL   |            18 |
| AL        |         1 |         13 | Butler County   |        1013 | Republican      | AL      | Butler County, AL   |                        9088 |            8039 |              1049 |                     0.11 | AL        |      161532 | Butler County   |        20947 |            9964 |     2011976894 |         2726814 |         776.82 |            1.05 |      31.75 |     -86.68 |  813930 |              1 | Butler County   |             2507 |       16.39 | Butler County   |               5271 |         34.4  | Butler County, AL   |            22 |
| AL        |         1 |         15 | Calhoun County  |        1015 | Republican      | AL      | Calhoun County, AL  |                       49649 |           45252 |              4397 |                     0.08 | AL        |      161533 | Calhoun County  |       118572 |           53289 |     1569189995 |        16624267 |         605.86 |            6.41 |      33.77 |     -85.82 |  813930 |              7 | Calhoun County  |            12582 |       14.3  | Calhoun County  |              29470 |         33.6  | Calhoun County, AL  |            22 |
| AL        |         1 |         19 | Cherokee County |        1019 | Republican      | AL      | Cherokee County, AL |                       11268 |           10363 |               905 |                     0.08 | AL        |      161535 | Cherokee County |        25989 |           16267 |     1434075952 |       119858898 |         553.7  |           46.27 |      34.06 |     -85.65 |  813930 |              1 | Cherokee County |             2993 |       14.9  | Cherokee County |               6225 |         31    | Cherokee County, AL |            22 |
| AL        |         1 |         21 | Chilton County  |        1021 | Republican      | AL      | Chilton County, AL  |                       19383 |           17982 |              1401 |                     0.07 | AL        |      161536 | Chilton County  |        43643 |           19278 |     1794483586 |        20586383 |         692.85 |            7.94 |      32.85 |     -86.72 |  813930 |              1 | Chilton County  |             4234 |       13.2  | Chilton County  |              10250 |         32    | Chilton County, AL  |            22 |
| AL        |         1 |         23 | Choctaw County  |        1023 | Republican      | AL      | Choctaw County, AL  |                        4791 |            4297 |               494 |                     0.1  | AL        |      161537 | Choctaw County  |        13859 |            7269 |     2365954748 |        19059251 |         913.5  |            7.35 |      31.99 |     -88.24 |  813930 |              4 | Choctaw County  |             1960 |       18.89 | Choctaw County  |               3493 |         33.79 | Choctaw County, AL  |            22 |
| AL        |         1 |         25 | Clarke County   |        1025 | Republican      | AL      | Clarke County, AL   |                        8374 |            7116 |              1258 |                     0.15 | AL        |      161538 | Clarke County   |        25833 |           12638 |     3207609488 |        36542656 |        1238.46 |           14.1  |      31.68 |     -87.81 |  813930 |              2 | Clarke County   |             2948 |       15.8  | Clarke County   |               5630 |         30.2  | Clarke County, AL   |            22 |
| AL        |         1 |         33 | Colbert County  |        1033 | Republican      | AL      | Colbert County, AL  |                       24026 |           21922 |              2104 |                     0.08 | AL        |      161542 | Colbert County  |        54428 |           25758 |     1534877333 |        76430813 |         592.61 |           29.51 |      34.7  |     -87.8  |  813930 |             14 | Colbert County  |             6928 |       16.8  | Colbert County  |              12260 |         29.7  | Colbert County, AL  |            22 |

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
source_4.csv
source_5.csv
test: test_0.csv
test_1.csv
test_2.csv
test_3.csv
test_4.csv
test_5.csv