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:
| LBE       |   CONGRESSIONAL_DISTRICT_CODE |   LEGISLATIVE_DISTRICT_CODE | PRECINCT   | PARTY         |   POLLS |   EARLY_VOING |   ABSENTEE |   PROVISIONAL |   ELIGIBLE_VOTERS |
|:----------|------------------------------:|----------------------------:|:-----------|:--------------|--------:|--------------:|-----------:|--------------:|------------------:|
| Frederick |                             8 |                          04 | 018-003    | DEMOCRAT      |     202 |            78 |         28 |             2 |               392 |
| Frederick |                             8 |                          04 | 018-003    | GREEN         |       0 |             0 |          0 |             0 |                 1 |
| Frederick |                             8 |                          04 | 018-003    | LIBERTARIAN   |       4 |             1 |          1 |             0 |                 7 |
| Frederick |                             8 |                          04 | 018-003    | OTHER PARTIES |       2 |             0 |          0 |             0 |                 4 |
| Frederick |                             8 |                          04 | 018-003    | REPUBLICAN    |     467 |            78 |         22 |             7 |               675 |
| Frederick |                             8 |                          04 | 018-003    | UNAFFILIATED  |     149 |            29 |         15 |             5 |               276 |
| Frederick |                             8 |                          04 | 019-001    | DEMOCRAT      |     183 |            32 |         12 |             1 |               296 |
| Frederick |                             8 |                          04 | 019-001    | GREEN         |       1 |             0 |          0 |             0 |                 1 |
| Frederick |                             8 |                          04 | 019-001    | LIBERTARIAN   |       7 |             1 |          1 |             1 |                10 |
| Frederick |                             8 |                          04 | 019-001    | OTHER PARTIES |       2 |             1 |          0 |             0 |                 3 |


Target Schema:
| PRECINCT   |   ELIGIBLE_VOTERS |   POLLS |   EARLY_VOING |   ABSENTEE |   PROVISIONAL |
|:-----------|------------------:|--------:|--------------:|-----------:|--------------:|
| 001-000    |               612 |     408 |            39 |         19 |             3 |
| 001-001    |             27791 |   13648 |          5179 |       1247 |           462 |
| 001-002    |             13695 |    6576 |          2601 |        495 |           307 |
| 001-003    |             14068 |    6283 |          3236 |        512 |           258 |
| 001-004    |             12918 |    5424 |          3067 |        567 |           213 |
| 001-005    |             11399 |    5094 |          2285 |        317 |           194 |
| 001-006    |              9058 |    3938 |          1931 |        260 |           132 |
| 001-007    |              6237 |    3284 |           881 |        223 |           114 |
| 001-008    |              6015 |    2583 |          1239 |        200 |            60 |
| 001-009    |              4288 |    1906 |           934 |        134 |            76 |

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