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:
|   TeamID | TeamName      |
|---------:|:--------------|
|     3101 | Abilene Chr   |
|     3102 | Air Force     |
|     3103 | Akron         |
|     3104 | Alabama       |
|     3105 | Alabama A&M   |
|     3106 | Alabama St    |
|     3107 | Albany NY     |
|     3108 | Alcorn St     |
|     3109 | Alliant Intl  |
|     3110 | American Univ |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   Team |   Opp |
|-------:|------:|
|   3110 |  3124 |
|   3110 |  3129 |
|   3110 |  3173 |
|   3110 |  3195 |
|   3110 |  3211 |
|   3110 |  3212 |
|   3110 |  3251 |
|   3110 |  3257 |
|   3110 |  3263 |
|   3110 |  3266 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|   Season |   TeamID |   reg_Win_Pct |   reg_Games_Played |   reg_Avg_Pts |   reg_Std_Pts |   reg_Avg_Margin |   reg_Std_Margin |
|---------:|---------:|--------------:|-------------------:|--------------:|--------------:|-----------------:|-----------------:|
|     2008 |     3418 |       59.0714 |            9.92911 |     -10.2143  |       15.2421 |         0.214286 |               28 |
|     2008 |     3419 |       63.5    |            9.94727 |       1.93333 |       14.3501 |         0.566667 |               30 |
|     2008 |     3420 |       58.8667 |            7.70908 |      -7.53333 |       15.0051 |         0.3      |               30 |
|     2008 |     3421 |       63.8621 |           10.3569  |      -4.72414 |       14.837  |         0.37931  |               29 |
|     2008 |     3422 |       52.6333 |           11.0656  |     -12.5667  |       15.7429 |         0.2      |               30 |
|     2008 |     3423 |       62.1935 |           12.3704  |      -1.48387 |       17.2759 |         0.548387 |               31 |
|     2008 |     3424 |       59.5667 |           10.9219  |      -9.7     |       15.7177 |         0.266667 |               30 |
|     2008 |     3425 |       62.6333 |           11.7047  |       2       |       13.9086 |         0.566667 |               30 |
|     2008 |     3426 |       68.3214 |           15.1537  |       4.82143 |       21.7001 |         0.642857 |               28 |
|     2008 |     3427 |       68.7742 |           10.6324  |       7.93548 |       16.3828 |         0.709677 |               31 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
|   Season | Seed   |   TeamID |   seed_num |
|---------:|:-------|---------:|-----------:|
|     1998 | W01    |     3330 |          1 |
|     1998 | W02    |     3163 |          2 |
|     1998 | W03    |     3112 |          3 |
|     1998 | W04    |     3301 |          4 |
|     1998 | W05    |     3272 |          5 |
|     1998 | W06    |     3438 |          6 |
|     1998 | W07    |     3208 |          7 |
|     1998 | W08    |     3307 |          8 |
|     1998 | W09    |     3304 |          9 |
|     1998 | W10    |     3203 |         10 |


Target Schema:
|   Team |   Opp | Team_Name     | Opp_Name   | Team_Seed   | Opp_Seed   |   Season_x |   TeamID_x |   reg_Win_Pct_x |   reg_Games_Played_x |   reg_Avg_Pts_x |   reg_Std_Pts_x |   reg_Avg_Margin_x |   reg_Std_Margin_x |   Season_y |   TeamID_y |   reg_Win_Pct_y |   reg_Games_Played_y |   reg_Avg_Pts_y |   reg_Std_Pts_y |   reg_Avg_Margin_y |   reg_Std_Margin_y | seed_diff   |
|-------:|------:|:--------------|:-----------|:------------|:-----------|-----------:|-----------:|----------------:|---------------------:|----------------:|----------------:|-------------------:|-------------------:|-----------:|-----------:|----------------:|---------------------:|----------------:|----------------:|-------------------:|-------------------:|:------------|
|   3110 |  3124 | American Univ | Baylor     | Z14         | Z08        |       1998 |       3110 |         72.8148 |              10.7024 |         5.48148 |         15.6411 |           0.777778 |                 27 |       1998 |       3124 |         74.5385 |             12.653   |         7.26923 |         24.6975 |           0.615385 |                 26 | Z14         |
|   3110 |  3124 | American Univ | Baylor     | Z14         | Z08        |       1998 |       3110 |         72.8148 |              10.7024 |         5.48148 |         15.6411 |           0.777778 |                 27 |       1999 |       3124 |         70.2414 |             13.5216  |         5.13793 |         18.8939 |           0.551724 |                 29 | Z14         |
|   3110 |  3124 | American Univ | Baylor     | Z14         | Z08        |       1998 |       3110 |         72.8148 |              10.7024 |         5.48148 |         15.6411 |           0.777778 |                 27 |       2000 |       3124 |         63.1111 |             11.45    |       -11.8889  |         20.7889 |           0.259259 |                 27 | Z14         |
|   3110 |  3124 | American Univ | Baylor     | Z14         | Z08        |       1998 |       3110 |         72.8148 |              10.7024 |         5.48148 |         15.6411 |           0.777778 |                 27 |       2001 |       3124 |         77.8214 |             13.2862  |        12.4286  |         20.61   |           0.714286 |                 28 | Z14         |
|   3110 |  3124 | American Univ | Baylor     | Z14         | Z08        |       1998 |       3110 |         72.8148 |              10.7024 |         5.48148 |         15.6411 |           0.777778 |                 27 |       2002 |       3124 |         77.9677 |              9.94479 |        13.3226  |         16.0839 |           0.83871  |                 31 | Z14         |
|   3110 |  3124 | American Univ | Baylor     | Z14         | Z08        |       1998 |       3110 |         72.8148 |              10.7024 |         5.48148 |         15.6411 |           0.777778 |                 27 |       2003 |       3124 |         76.2667 |             17.0959  |        16.4333  |         25.6914 |           0.666667 |                 30 | Z14         |
|   3110 |  3124 | American Univ | Baylor     | Z14         | Z08        |       1998 |       3110 |         72.8148 |              10.7024 |         5.48148 |         15.6411 |           0.777778 |                 27 |       2004 |       3124 |         76.1935 |             11.0858  |        14.5484  |         17.8845 |           0.741935 |                 31 | Z14         |
|   3110 |  3124 | American Univ | Baylor     | Z14         | Z08        |       1998 |       3110 |         72.8148 |              10.7024 |         5.48148 |         15.6411 |           0.777778 |                 27 |       2005 |       3124 |         74.1667 |             11.2987  |        13.1667  |         12.211  |           0.9      |                 30 | Z14         |
|   3110 |  3124 | American Univ | Baylor     | Z14         | Z08        |       1998 |       3110 |         72.8148 |              10.7024 |         5.48148 |         15.6411 |           0.777778 |                 27 |       2006 |       3124 |         74.8333 |             11.4653  |        14.2     |         17.3492 |           0.8      |                 30 | Z14         |
|   3110 |  3124 | American Univ | Baylor     | Z14         | Z08        |       1998 |       3110 |         72.8148 |              10.7024 |         5.48148 |         15.6411 |           0.777778 |                 27 |       2007 |       3124 |         74.1875 |             13.6723  |        12.9375  |         21.085  |           0.78125  |                 32 | Z14         |

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
source_2.csv
source_3.csv
test: test_0.csv
test_1.csv
test_2.csv
test_3.csv