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:
| Course   | Course Prefix   |   Course Suffix | Department   | First Begin Time   | First Days   | First End Time   | First Instructor        |   First Instructor UID | First Room   | Link   |   Max Units |   Min Units | Mode   |   Reg Count |   Seats | Second Begin Time   | Second Days   | Second End Time   | Second Instructor   | Second Instructor UID   | Second Room   |   Section |   Session |   Term | Title                               |
|:---------|:----------------|----------------:|:-------------|:-------------------|:-------------|:-----------------|:------------------------|-----------------------:|:-------------|:-------|------------:|------------:|:-------|------------:|--------:|:--------------------|:--------------|:------------------|:--------------------|:------------------------|:--------------|----------:|----------:|-------:|:------------------------------------|
| WRIT-340 | WRIT            |             340 | BUCO         | 15:00:00           | TH           | 17:20:00         | Byars, Stephen, Michael |            4.14182e+09 | ACC310       |        |           4 |           4 | C      |          19 |      19 |                     |               |                   |                     |                         |               |     66763 |        58 |  20162 | Advanced Writing                    |
| WRIT-340 | WRIT            |             340 | BUCO         | 12:00:00           | MW           | 14:20:00         | Hansen, Clark, C        |            3.77997e+09 | JKP102       |        |           4 |           4 | C      |          19 |      19 |                     |               |                   |                     |                         |               |     66746 |        58 |  20162 | Advanced Writing                    |
| ACCT-370 | ACCT            |             370 | ACCT         | 10:00:00           | F            | 11:50:00         | Hopkins, Merle, W       |            3.78335e+09 | HOH EDI      |        |           0 |           0 | L      |          98 |     135 |                     |               |                   |                     |                         |               |     14029 |         1 |  20163 | External Financial Reporting Issues |
| ACCT-370 | ACCT            |             370 | ACCT         | 12:00:00           | MW           | 13:50:00         | Hopkins, Merle, W       |            3.78335e+09 | JFF236       | A      |           4 |           4 | C      |          48 |      51 |                     |               |                   |                     |                         |               |     14027 |         1 |  20163 | External Financial Reporting Issues |
| ACCT-370 | ACCT            |             370 | ACCT         | 10:00:00           | MW           | 11:50:00         | Hopkins, Merle, W       |            3.78335e+09 | JFF236       |        |           4 |           4 | C      |          50 |      51 |                     |               |                   |                     |                         |               |     14026 |         1 |  20163 | External Financial Reporting Issues |
| ACCT-371 | ACCT            |             371 | ACCT         | 10:00:00           | F            | 11:50:00         | Porter, Leslie, Robert  |            2.44785e+09 | HOH EDI      |        |           0 |           0 | D      |         102 |     150 |                     |               |                   |                     |                         |               |     14044 |         1 |  20163 | Introduction to Accounting Systems  |
| ACCT-371 | ACCT            |             371 | ACCT         | 12:00:00           | TH           | 13:50:00         | Porter, Leslie, Robert  |            2.44785e+09 | JFF236       |        |           4 |           4 | C      |          48 |      52 |                     |               |                   |                     |                         |               |     14042 |         1 |  20163 | Introduction to Accounting Systems  |
| ACCT-371 | ACCT            |             371 | ACCT         | 10:00:00           | TH           | 11:50:00         | Porter, Leslie, Robert  |            2.44785e+09 | JFF236       |        |           4 |           4 | C      |          54 |      54 |                     |               |                   |                     |                         |               |     14041 |         1 |  20163 | Introduction to Accounting Systems  |
| ACCT-372 | ACCT            |             372 | ACCT         | 16:00:00           | TH           | 17:50:00         | Jackson, Cecil, W       |            9.96825e+09 | JFF LL101    |        |           2 |           2 | C      |          39 |      42 |                     |               |                   |                     |                         |               |     14049 |       442 |  20163 | Internal Reporting Issues           |
| ACCT-372 | ACCT            |             372 | ACCT         | 08:00:00           | TH           | 09:50:00         | Tinseth, Andrew         |            5.73647e+09 | ACC303       |        |           2 |           2 | C      |          39 |      42 |                     |               |                   |                     |                         |               |     14050 |       442 |  20163 | Internal Reporting Issues           |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
| Room     |   Size |
|:---------|-------:|
| ACC 306B |     16 |
| ACC201   |     48 |
| ACC205   |     36 |
| ACC236   |     39 |
| ACC303   |     46 |
| ACC306B  |     16 |
| ACC310   |     54 |
| ACC312   |     20 |
| BRI202   |     42 |
| BRI202A  |     34 |


Target Schema:
| Department     | 20153   | 20161   | 20162   |
|:---------------|:--------|:--------|:--------|
| ACCT           | 3407.0  | 2985.0  | 241.0   |
| BAEP           | 977.0   | 954.0   | 11.0    |
| BUCO           | 599.0   | 282.0   | 117.0   |
| DSO            | 3472.0  | 2456.0  | 396.0   |
| EMBA Program   |         |         | 425.0   |
| FBE            | 2619.0  | 2912.0  | 458.0   |
| FIM Program    |         | 140.0   |         |
| FT MBA Program |         | 651.0   |         |
| G Programs     | 56.0    | 35.0    |         |
| IBEAR Program  |         | 57.0    | 57.0    |

Return only the final code in markdown codeblock format, without any additional text or explanation. 



target: target.csv
train: source_0.csv
source_1.csv
test: test_0.csv
test_1.csv