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 |
|------------:|:--------|----------:|-----------:|-----:|--------:|--------:|--------:|-------:|-----:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|-------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|---------:|
|          48 | TX      |     78944 |          3 |   30 |       0 |      20 |       0 |      0 |   70 |        0 |     1736 |       20 |     1290 |        0 |        0 |       30 |      132 |       20 |      117 |        0 |        0 |      0 |        0 |        0 |       30 |      477 |        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 |     1149 |        0 |        0 |       40 |       54 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |       30 |      135 |       30 |      151 |        0 |        0 |       30 |      112 |
|          48 | TX      |     77840 |          3 |  830 |     370 |     390 |      50 |    330 | 1720 |      490 |    50670 |      730 |    41283 |      280 |      362 |      150 |      399 |      140 |      276 |      110 |     1528 |      0 |      130 |      137 |       80 |     1122 |      170 |     3989 |       40 |      223 |      120 |     1747 |        0 |        0 |      190 |    11684 |      190 |     3405 |       40 |       95 |      150 |      188 |      140 |      460 |      180 |      703 |       90 |      513 |      140 |      813 |      830 |    34789 |      340 |      509 |      210 |      329 |       60 |       39 |       40 |        8 |        0 |        0 |        0 |        0 |       30 |       50 |        0 |        0 |      800 |     4592 |      810 |     4815 |      200 |      392 |      610 |     1608 |
|          51 | VA      |     22312 |          3 | 2280 |    1240 |     680 |     290 |   1170 | 4200 |     1240 |   140297 |     2040 |   119023 |      810 |      526 |      410 |     1340 |      370 |      932 |      340 |     2820 |      0 |      340 |      395 |      130 |     1381 |      400 |    11258 |       90 |      416 |      250 |     3249 |        0 |        0 |     1210 |    75322 |     1210 |    23489 |     1120 |     3246 |       60 |       54 |      840 |     2717 |     1210 |     6403 |      750 |     7594 |      950 |     2488 |     2260 |    92500 |      850 |     1181 |      510 |      695 |      110 |       73 |       40 |        9 |        0 |        0 |        0 |        0 |      110 |      124 |        0 |        0 |     2160 |    12744 |     2190 |    13436 |      470 |      976 |     1770 |     5171 |
|          40 | OK      |     73430 |          1 |  180 |     100 |      40 |      30 |    110 |  270 |       80 |     2307 |      130 |     1593 |       40 |       25 |        0 |        0 |       30 |       18 |       20 |      113 |      0 |       30 |      -20 |       30 |      176 |       30 |      321 |       30 |      196 |        0 |        0 |        0 |        0 |       30 |      870 |       30 |      461 |        0 |        0 |       20 |       25 |        0 |        0 |       30 |       56 |        0 |        0 |        0 |        0 |       70 |      456 |       30 |        7 |       30 |       25 |        0 |        0 |        0 |        0 |       80 |      185 |       70 |      167 |       50 |       63 |        0 |        0 |       60 |       41 |       80 |       65 |        0 |        0 |      150 |      296 |
|          48 | TX      |     79510 |          4 |  320 |      30 |     290 |       0 |    200 |  910 |      300 |    27476 |      290 |    21999 |      120 |      105 |       50 |      183 |       50 |      119 |       60 |      572 |     60 |       50 |      245 |       40 |      470 |       90 |     2262 |        0 |        0 |       60 |     1075 |        0 |        0 |       90 |     7554 |       90 |     1721 |        0 |        0 |       70 |      117 |       80 |      184 |       80 |      315 |       70 |      415 |       60 |      280 |      320 |    19570 |      160 |      301 |      130 |      238 |       40 |       29 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |      320 |     2440 |      320 |     2604 |       70 |      224 |      240 |      854 |
|          48 | TX      |     77857 |          5 |   50 |       0 |      40 |       0 |     40 |  140 |       50 |     9939 |       40 |     4559 |       30 |       40 |        0 |        0 |        0 |        0 |        0 |        0 |     20 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |       30 |     5974 |       30 |      679 |        0 |        0 |       30 |       60 |       20 |       76 |       30 |      141 |        0 |        0 |       20 |      146 |       50 |     8327 |       20 |       22 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |       50 |     1643 |       50 |     1756 |        0 |        0 |       30 |      145 |
|          50 | VT      |      5077 |          5 |   50 |       0 |      40 |       0 |     40 |  120 |       30 |    10763 |       40 |     6305 |       40 |       62 |       20 |      169 |        0 |        0 |        0 |        0 |      0 |        0 |        0 |        0 |        0 |       20 |      670 |        0 |        0 |        0 |        0 |        0 |        0 |       40 |     9579 |       40 |     1294 |       40 |      544 |        0 |        0 |       40 |      274 |       40 |      821 |       30 |      298 |       30 |      160 |       50 |     8365 |       20 |       17 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |       50 |     1848 |       50 |     1918 |       30 |      185 |        0 |        0 |
|          34 | NJ      |      7857 |          4 |  160 |      50 |     100 |       0 |    110 |  370 |      110 |    13665 |      130 |    10247 |       90 |      149 |       60 |      187 |       50 |      120 |        0 |        0 |      0 |        0 |        0 |       30 |      336 |       50 |     1476 |       30 |      252 |       40 |      667 |        0 |        0 |      120 |    10039 |      120 |     2388 |      100 |      276 |       20 |       30 |      110 |      717 |      120 |     1045 |       90 |      802 |      110 |      218 |      160 |     9431 |       70 |      108 |       50 |       74 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |        0 |      160 |     1348 |      160 |     1403 |       40 |       72 |      120 |      392 |
|          36 | NY      |     13603 |          6 |    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 |        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 |
|          36 | NY      |     10709 |          5 | 1040 |     220 |     740 |      80 |    790 | 2760 |      980 |   144999 |      880 |   102308 |      820 |     1726 |      580 |     4896 |      530 |     3918 |      200 |     4798 |      0 |      470 |     1163 |      190 |     4719 |      320 |    14284 |       80 |      628 |      260 |     6434 |       40 |      762 |      970 |   135902 |      970 |    34381 |      870 |     6886 |      100 |      159 |      860 |    11807 |      970 |    18957 |      700 |     8558 |      920 |     2593 |     1030 |    99982 |      490 |      541 |      170 |      196 |      100 |       60 |       40 |       14 |        0 |        0 |        0 |        0 |        0 |        0 |      220 |      536 |     1030 |    17685 |     1030 |    18495 |      270 |     1369 |      700 |     3810 |


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