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 |
|--------------------------:|----------------------------:|-------------------------:|:---------------------------------------------------------------------------|:-------------------------------------------|:-----------------|--------------:|:-------------------------------------|:-----------------|:--------------------------|--------------------:|-------------------:|
|                   17111.7 |                     4718    |                  5647.64 | 442 - DISORDERS OF LIVER EXCEPT MALIG,CIRR,ALC HEPA W CC                   | KY - Covington                             | FORT THOMAS      |        180001 | ST ELIZABETH FT THOMAS               | KY               | 85 NORTH GRAND AVENUE     |               41075 |                 11 |
|                   94244.9 |                    14382    |                 17369.3  | 247 - PERC CARDIOVASC PROC W DRUG-ELUTING STENT W/O MCC                    | MO - Columbia                              | KIRKSVILLE       |        260022 | NORTHEAST REGIONAL MEDICAL CENTER    | MO               | 315 S OSTEOPATHY          |               63501 |                 20 |
|                   17018.3 |                     4586.48 |                  5433.6  | 690 - KIDNEY & URINARY TRACT INFECTIONS W/O MCC                            | CT - Hartford                              | STAFFORD SPRINGS |         70008 | JOHNSON MEMORIAL HOSPITAL            | CT               | 201 CHESTNUT HILL RD      |                6076 |                 50 |
|                   11140.7 |                     2517.55 |                  3628.8  | 310 - CARDIAC ARRHYTHMIA & CONDUCTION DISORDERS W/O CC/MCC                 | OH - Columbus                              | MARION           |        360011 | MARION GENERAL HOSPITAL              | OH               | 1000 MCKINLEY PARK DRIVE  |               43302 |                 20 |
|                   23221   |                     4729.73 |                  8766.64 | 305 - HYPERTENSION W/O MCC                                                 | KY - Lexington                             | LEXINGTON        |        180067 | UNIVERSITY OF KENTUCKY HOSPITAL      | KY               | 800 ROSE STREET           |               40536 |                 11 |
|                   26421.9 |                     5791.5  |                  6830.5  | 065 - INTRACRANIAL HEMORRHAGE OR CEREBRAL INFARCTION W CC OR TPA IN 24 HRS | UT - Ogden                                 | OGDEN            |        460005 | OGDEN REGIONAL MEDICAL CENTER        | UT               | 5475 SOUTH 500 EAST       |               84405 |                 24 |
|                   55293.2 |                     5771.36 |                  6457.07 | 281 - ACUTE MYOCARDIAL INFARCTION, DISCHARGED ALIVE W CC                   | PA - Philadelphia                          | PHILADELPHIA     |        390026 | CHESTNUT HILL HOSPITAL               | PA               | 8835 GERMANTOWN AVE       |               19118 |                 14 |
|                   37507.6 |                    17731.8  |                 19013.3  | 164 - MAJOR CHEST PROCEDURES W CC                                          | MA - Springfield                           | SPRINGFIELD      |        220066 | MERCY MEDICAL CTR                    | MA               | 271 CAREW STREET          |                1104 |                 20 |
|                   38309   |                     6984.21 |                  7784.79 | 372 - MAJOR GASTROINTESTINAL DISORDERS & PERITONEAL INFECTIONS W CC        | CA - Orange County                         | MISSION VIEJO    |         50567 | MISSION HOSPITAL REGIONAL MED CENTER | CA               | 27700 MEDICAL CENTER RD   |               92691 |                 14 |
|                   14617.5 |                     3504.65 |                  4786.55 | 392 - ESOPHAGITIS, GASTROENT & MISC DIGEST DISORDERS W/O MCC               | NC - Greenville                            | AHOSKIE          |        340099 | VIDANT ROANOKE CHOWAN HOSPITAL       | NC               | 500 S ACADEMY ST          |               27910 |                 20 |


Target Schema:
|   provider_zip_code |   provider_id |   average_covered_charges |   average_total_payments |   average_medicare_payments |
|--------------------:|--------------:|--------------------------:|-------------------------:|----------------------------:|
|                1040 |        220024 |                  10606.6  |                  7722.36 |                     6745.82 |
|                1060 |        220015 |                  18174.4  |                  8546.35 |                     7461.55 |
|                1069 |        220030 |                  14887.1  |                  5935.89 |                     4975.09 |
|                1082 |        220050 |                   9332.52 |                  7479.15 |                     6567.99 |
|                1085 |        220065 |                  15788.3  |                  7744.97 |                     6597.18 |
|                1104 |        220066 |                  19808.3  |                 11794    |                    10739.5  |
|                1199 |        220077 |                  31173.7  |                 18218.4  |                    16148.2  |
|                1201 |        220046 |                  18558.1  |                 11572.1  |                    10560.3  |
|                1301 |        220016 |                  14919.1  |                  8728.75 |                     7593.88 |
|                1432 |        220098 |                  17004.6  |                  8245.96 |                     7104.86 |

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