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:
|   STATEFIPS | STATE   |   zipcode |   AGI_STUB |   N1 |   MARS1 |   MARS2 |   MARS4 |   PREP |    N2 |   NUMDEP |   A00100 |   N00200 |   A00200 |   N00300 |   A00300 |   N00600 |   A00600 |   N00650 |   A00650 |   N00900 |   A00900 |   SCHF |   N01000 |   A01000 |   N01400 |   A01400 |   N01700 |   A01700 |   N02300 |   A02300 |   N02500 |   A02500 |   N03300 |   A03300 |   N00101 |   A00101 |   N04470 |   A04470 |   N18425 |   A18425 |   N18450 |   A18450 |   N18500 |   A18500 |   N18300 |   A18300 |   N19300 |   A19300 |   N19700 |   A19700 |   N04800 |   A04800 |   N07100 |   A07100 |   N07220 |   A07220 |   N07180 |   A07180 |   N07260 |   A07260 |   N59660 |   A59660 |   N59720 |   A59720 |   N11070 |   A11070 |   N09600 |   A09600 |   N06500 |   A06500 |   N10300 |   A10300 |   N11901 |   A11901 |   N11902 |   A11902 |
|------------:|:--------|----------:|-----------:|-----:|--------:|--------:|--------:|-------:|------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|-------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|
|          31 | NE      |     68927 |          5 |   40 |       0 |      40 |       0 |     30 |   110 |       30 |     5132 |       30 |     2154 |       30 |       47 |        0 |        0 |        0 |        0 |        0 |        0 |      0 |        0 |        0 |       20 |      240 |        0 |        0 |        0 |        0 |       30 |      623 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |       30 |      147 |        0 |        0 |       40 |     4096 |       40 |       35 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |       40 |      646 |       40 |      762 |       20 |      370 |        0 |        0 |
|          29 | MO      |     65301 |          1 | 6710 |    4120 |    1130 |    1340 |   4150 | 10940 |     3860 |    85843 |     5290 |    66635 |     1460 |     1278 |      590 |      932 |      530 |      607 |      790 |     5663 |    100 |      420 |      146 |      430 |     2050 |     1000 |     7546 |      620 |     2082 |      260 |      396 |        0 |        0 |      260 |     3820 |      260 |     4071 |       70 |      118 |      160 |      100 |      180 |      223 |      260 |      503 |      100 |      521 |      150 |      370 |     2890 |    17208 |      900 |      276 |      290 |      102 |       80 |       28 |        0 |        0 |     2460 |     6480 |     2220 |     5986 |     1710 |     2211 |        0 |        0 |     2300 |     1535 |     2920 |     2364 |      480 |      349 |     5630 |    12383 |
|          46 | SD      |     57448 |          4 |   30 |       0 |      20 |       0 |     20 |    70 |       20 |     3713 |       20 |     1164 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |      0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |       30 |     2932 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |       20 |      345 |       30 |      458 |        0 |        0 |        0 |        0 |
|          38 | ND      |     58316 |          3 |  250 |      50 |     100 |     100 |    130 |   690 |      340 |    15467 |      240 |    13051 |       30 |       21 |        0 |        0 |        0 |        0 |       40 |      211 |      0 |        0 |        0 |        0 |        0 |       50 |      923 |       60 |      291 |       50 |      494 |        0 |        0 |        0 |        0 |       40 |      854 |        0 |        0 |        0 |        0 |        0 |        0 |       30 |       87 |        0 |        0 |       20 |       44 |      250 |    10337 |      140 |      254 |      130 |      214 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |      240 |     1216 |      240 |     1280 |       50 |      135 |      200 |      682 |
|          39 | OH      |     43511 |          2 |  120 |      40 |      70 |       0 |     60 |   240 |       70 |     4371 |      100 |     3002 |       40 |       29 |       40 |       27 |       30 |       14 |        0 |        0 |     30 |        0 |        0 |        0 |        0 |       30 |      567 |       40 |      226 |       40 |      168 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |      120 |     2271 |       60 |       36 |       30 |       26 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |      100 |      246 |      110 |      289 |       40 |       68 |       90 |      241 |
|          36 | NY      |     13334 |          1 |  220 |     140 |      40 |      30 |    110 |   320 |      100 |     2521 |      150 |     1625 |       50 |       16 |       20 |       22 |       40 |       24 |       50 |      302 |     30 |       20 |       36 |       20 |      103 |       40 |      365 |       20 |      132 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |       90 |      469 |       20 |        8 |        0 |        0 |        0 |        0 |        0 |        0 |       70 |      147 |       60 |      125 |       40 |       39 |        0 |        0 |       70 |       41 |       90 |       72 |        0 |        0 |      190 |      319 |
|          54 | WV      |     25837 |          2 |   40 |       0 |      40 |       0 |     50 |   100 |       30 |     1938 |       30 |     1522 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |      0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |       40 |     1140 |       30 |       38 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |       50 |      133 |       40 |      131 |        0 |        0 |       50 |      157 |
|          53 | WA      |     98422 |          5 | 1950 |     240 |    1640 |      70 |    950 |  5370 |     1780 |   263868 |     1760 |   207981 |     1370 |     1529 |      870 |     3317 |      800 |     2316 |      310 |     7329 |      0 |      680 |     3527 |      300 |     8872 |      540 |    18397 |      150 |     1168 |      350 |     7824 |        0 |        0 |     1640 |   224301 |     1640 |    41157 |       50 |      227 |     1490 |     4021 |     1610 |     8317 |     1640 |    12963 |     1500 |    18535 |     1480 |     5411 |     1950 |   198789 |      890 |     1177 |      380 |      512 |      170 |       91 |       80 |       25 |        0 |        0 |        0 |        0 |        0 |        0 |       30 |       84 |     1950 |    34066 |     1950 |    35280 |      670 |     2998 |     1200 |     4745 |
|          54 | WV      |     26181 |          5 |  350 |       0 |     330 |       0 |    170 |  1010 |      330 |    44732 |      330 |    34753 |      220 |      223 |      120 |      420 |      130 |      455 |       70 |     2272 |      0 |       90 |      374 |       50 |     1714 |      140 |     4665 |       20 |      129 |       70 |     1682 |        0 |        0 |      250 |    33131 |      250 |     5072 |      250 |     1787 |        0 |        0 |      250 |      312 |      250 |     2183 |      220 |     1330 |      220 |      994 |      350 |    34594 |      180 |      234 |      100 |      122 |       30 |       15 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |      350 |     5661 |      350 |     5839 |      100 |      299 |      260 |      926 |
|          51 | VA      |     22942 |          3 |  530 |     130 |     350 |      60 |    220 |  1290 |      410 |    33037 |      480 |    26062 |      180 |      173 |      110 |      327 |      100 |      242 |       90 |      754 |     20 |       80 |       -3 |       70 |      824 |      130 |     2870 |        0 |        0 |      110 |     1571 |        0 |        0 |      250 |    15368 |      250 |     4307 |      220 |      622 |       30 |       23 |      230 |      384 |      240 |     1097 |      210 |     2011 |      180 |      544 |      530 |    20757 |      240 |      367 |      170 |      262 |       40 |       18 |       40 |       13 |        0 |        0 |        0 |        0 |       30 |       42 |        0 |        0 |      500 |     2476 |      510 |     2671 |      130 |      227 |      390 |     1086 |


Target Schema:
|   zipcode |   AGI_STUB |              N1 |           A00100 |
|----------:|-----------:|----------------:|-----------------:|
|         0 |        546 |     7.56193e+07 |      4.85774e+09 |
|      1001 |         21 |  8780           | 458716           |
|      1002 |         21 |  9460           | 732849           |
|      1005 |         21 |  2230           | 122744           |
|      1007 |         21 |  7320           | 467891           |
|      1008 |         21 |   640           |  38487           |
|      1010 |         21 |  1830           | 121083           |
|      1011 |         21 |   600           |  30165           |
|      1012 |         21 |   330           |  18634           |
|      1013 |         21 | 10090           | 383618           |

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