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:
|   average_covered_charges |   average_medicare_payments |   average_total_payments | drg_definition                                                    | hospital_referral_region_hrr_description   | provider_city   |   provider_id | provider_name                               | provider_state   | provider_street_address   |   provider_zip_code |   total_discharges |
|--------------------------:|----------------------------:|-------------------------:|:------------------------------------------------------------------|:-------------------------------------------|:----------------|--------------:|:--------------------------------------------|:-----------------|:--------------------------|--------------------:|-------------------:|
|                  216797   |                    40782.6  |                 43018.2  | 870 - SEPTICEMIA OR SEVERE SEPSIS W MV >96 HOURS                  | WA - Tacoma                                | TACOMA          |        500129 | TACOMA GENERAL ALLENMORE HOSPITAL           | WA               | 315 S MLK JR WAY          |               98415 |                 43 |
|                   43166.9 |                    10109.3  |                 11657.2  | 871 - SEPTICEMIA OR SEVERE SEPSIS W/O MV 96+ HOURS W MCC          | WI - Milwaukee                             | WEST ALLIS      |        520139 | AURORA WEST ALLIS MEDICAL CENTER            | WI               | 8901 W LINCOLN AVE        |               53227 |                172 |
|                   44921.3 |                    19295    |                 23310.8  | 243 - PERMANENT CARDIAC PACEMAKER IMPLANT W CC                    | OR - Eugene                                | CORVALLIS       |        380014 | GOOD SAMARITAN REGIONAL MEDICAL CENTER      | OR               | 3600 NW SAMARITAN DRIVE   |               97330 |                 19 |
|                   27775.7 |                     4390.79 |                  5568.37 | 300 - PERIPHERAL VASCULAR DISORDERS W CC                          | TN - Jackson                               | JACKSON         |        440189 | TENNOVA HEALTHCARE-REGIONAL JACKSON         | TN               | 367 HOSPITAL BLVD         |               38305 |                 19 |
|                   81204.5 |                    11053.1  |                 14158.8  | 280 - ACUTE MYOCARDIAL INFARCTION, DISCHARGED ALIVE W MCC         | PA - Philadelphia                          | WYNNEWOOD       |        390195 | MAIN LINE HOSPITAL LANKENAU                 | PA               | 100 LANCASTER AVE         |               19096 |                 27 |
|                   24427.6 |                    10401.4  |                 11163.2  | 377 - G.I. HEMORRHAGE W MCC                                       | VA - Arlington                             | MANASSAS        |        490045 | NOVANT HEALTH PRINCE WILLIAM MEDICAL CENTER | VA               | 8700 SUDLEY RD            |               20110 |                 14 |
|                   30205.9 |                     5523.77 |                  6409.15 | 689 - KIDNEY & URINARY TRACT INFECTIONS W MCC                     | OH - Akron                                 | RAVENNA         |        360078 | ROBINSON MEMORIAL HOSPITAL                  | OH               | 6847 N CHESTNUT           |               44266 |                 13 |
|                  198767   |                    20820.6  |                 22550.9  | 236 - CORONARY BYPASS W/O CARDIAC CATH W/O MCC                    | SC - Greenville                            | ANDERSON        |        420027 | ANMED HEALTH                                | SC               | 800 N FANT ST             |               29621 |                 13 |
|                  290451   |                    32694    |                 44095.8  | 207 - RESPIRATORY SYSTEM DIAGNOSIS W VENTILATOR SUPPORT 96+ HOURS | GA - Atlanta                               | SNELLVILLE      |        110192 | EASTSIDE MEDICAL CENTER                     | GA               | 1700 MEDICAL WAY          |               30078 |                 12 |
|                   18333.1 |                     4326.59 |                  5205.06 | 389 - G.I. OBSTRUCTION W CC                                       | KY - Louisville                            | CAMPBELLSVILLE  |        180087 | TAYLOR REGIONAL HOSPITAL                    | KY               | 1700 OLD LEBANON ROAD     |               42718 |                 17 |


Target Schema:
|   provider_id | provider_name                    |   provider_zip_code |   average_covered_charges |   average_total_payments |   average_medicare_payments |
|--------------:|:---------------------------------|--------------------:|--------------------------:|-------------------------:|----------------------------:|
|         10001 | SOUTHEAST ALABAMA MEDICAL CENTER |               36301 |                   45757.6 |                 10177.4  |                     8907.12 |
|         10005 | MARSHALL MEDICAL CENTER SOUTH    |               35957 |                   17601.7 |                  7403.27 |                     5947.81 |
|         10006 | ELIZA COFFEE MEMORIAL HOSPITAL   |               35631 |                   56096.9 |                 11159.3  |                     9789.64 |
|         10007 | MIZELL MEMORIAL HOSPITAL         |               36467 |                   13795.6 |                  5329.49 |                     4439.95 |
|         10011 | ST VINCENT'S EAST                |               35235 |                   47487.8 |                 10781    |                     9547.65 |
|         10012 | DEKALB REGIONAL MEDICAL CENTER   |               35968 |                   44859.1 |                  6441.61 |                     5307.69 |
|         10016 | SHELBY BAPTIST MEDICAL CENTER    |               35007 |                   50042   |                  9516.92 |                     7829.44 |
|         10018 | CALLAHAN EYE HOSPITAL            |               35233 |                   31023.7 |                 10373.7  |                     8139.31 |
|         10019 | HELEN KELLER MEMORIAL HOSPITAL   |               35660 |                   26522.6 |                  7807.95 |                     6627.55 |
|         10021 | DALE MEDICAL CENTER              |               36360 |                   13505.8 |                  7073.42 |                     6158.56 |

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