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:
|   TrackID |   tlx |   tly |   brx |   bry |   frame |   lost |   occluded |   generated | label   | attributes   | video           |
|----------:|------:|------:|------:|------:|--------:|-------:|-----------:|------------:|:--------|:-------------|:----------------|
|        23 |   384 |   111 |   448 |   197 |       0 |      1 |          0 |           0 | brad    |              | ../MAH00011.MP4 |
|        23 |   384 |   111 |   448 |   197 |       1 |      1 |          0 |           1 | brad    |              | ../MAH00011.MP4 |
|        23 |   384 |   111 |   448 |   197 |       2 |      1 |          0 |           1 | brad    |              | ../MAH00011.MP4 |
|        23 |   384 |   111 |   448 |   197 |       3 |      1 |          0 |           1 | brad    |              | ../MAH00011.MP4 |
|        23 |   384 |   111 |   448 |   197 |       4 |      0 |          1 |           0 | brad    |              | ../MAH00011.MP4 |
|        23 |   383 |   110 |   447 |   196 |       5 |      0 |          1 |           1 | brad    |              | ../MAH00011.MP4 |
|        23 |   382 |   109 |   446 |   195 |       6 |      0 |          1 |           1 | brad    |              | ../MAH00011.MP4 |
|        23 |   381 |   108 |   445 |   194 |       7 |      0 |          1 |           1 | brad    |              | ../MAH00011.MP4 |
|        23 |   381 |   107 |   445 |   193 |       8 |      0 |          1 |           1 | brad    |              | ../MAH00011.MP4 |
|        23 |   380 |   106 |   444 |   192 |       9 |      0 |          1 |           1 | brad    |              | ../MAH00011.MP4 |


Table #2
Filename: source_1.csv
Sample Rows in Markdown:
|   TrackID |   tlx |   tly |   brx |   bry |   frame |   lost |   occluded |   generated | label   | attributes   | video           |
|----------:|------:|------:|------:|------:|--------:|-------:|-----------:|------------:|:--------|:-------------|:----------------|
|        12 |   443 |   152 |   484 |   202 |    2400 |      0 |          1 |           0 | piotr   |              | ../MAH00013.MP4 |
|        12 |   442 |   151 |   483 |   201 |    2401 |      0 |          1 |           1 | piotr   |              | ../MAH00013.MP4 |
|        12 |   442 |   150 |   483 |   200 |    2402 |      0 |          1 |           1 | piotr   |              | ../MAH00013.MP4 |
|        12 |   442 |   150 |   482 |   199 |    2403 |      0 |          1 |           1 | piotr   |              | ../MAH00013.MP4 |
|        12 |   441 |   149 |   482 |   199 |    2404 |      0 |          1 |           1 | piotr   |              | ../MAH00013.MP4 |
|        12 |   441 |   149 |   482 |   198 |    2405 |      0 |          1 |           1 | piotr   |              | ../MAH00013.MP4 |
|        12 |   441 |   148 |   481 |   197 |    2406 |      0 |          1 |           1 | piotr   |              | ../MAH00013.MP4 |
|        12 |   441 |   147 |   481 |   197 |    2407 |      0 |          1 |           1 | piotr   |              | ../MAH00013.MP4 |
|        12 |   440 |   147 |   481 |   196 |    2408 |      0 |          1 |           1 | piotr   |              | ../MAH00013.MP4 |
|        12 |   440 |   146 |   480 |   195 |    2409 |      0 |          1 |           1 | piotr   |              | ../MAH00013.MP4 |


Table #3
Filename: source_2.csv
Sample Rows in Markdown:
|   TrackID |   tlx |   tly |   brx |   bry |   frame |   lost |   occluded |   generated | label   | attributes   | video           |
|----------:|------:|------:|------:|------:|--------:|-------:|-----------:|------------:|:--------|:-------------|:----------------|
|        55 |   361 |   124 |   395 |   163 |     300 |      0 |          1 |           0 | brad    |              | ../MAH00004.MP4 |
|        55 |   361 |   123 |   395 |   162 |     301 |      0 |          1 |           1 | brad    |              | ../MAH00004.MP4 |
|        55 |   361 |   123 |   395 |   162 |     302 |      0 |          1 |           1 | brad    |              | ../MAH00004.MP4 |
|        55 |   362 |   122 |   395 |   161 |     303 |      0 |          1 |           1 | brad    |              | ../MAH00004.MP4 |
|        55 |   362 |   122 |   395 |   161 |     304 |      0 |          1 |           1 | brad    |              | ../MAH00004.MP4 |
|        55 |   362 |   122 |   395 |   160 |     305 |      0 |          1 |           1 | brad    |              | ../MAH00004.MP4 |
|        55 |   363 |   121 |   396 |   160 |     306 |      0 |          1 |           1 | brad    |              | ../MAH00004.MP4 |
|        55 |   363 |   121 |   396 |   159 |     307 |      0 |          1 |           1 | brad    |              | ../MAH00004.MP4 |
|        55 |   363 |   121 |   396 |   159 |     308 |      0 |          1 |           1 | brad    |              | ../MAH00004.MP4 |
|        55 |   364 |   120 |   396 |   158 |     309 |      0 |          1 |           1 | brad    |              | ../MAH00004.MP4 |


Table #4
Filename: source_3.csv
Sample Rows in Markdown:
|   TrackID |   tlx |   tly |   brx |   bry |   frame |   lost |   occluded |   generated | label   | attributes   | video           |
|----------:|------:|------:|------:|------:|--------:|-------:|-----------:|------------:|:--------|:-------------|:----------------|
|        45 |   349 |   112 |   373 |   133 |     600 |      0 |          1 |           0 | megan   |              | ../MAH00005.MP4 |
|        45 |   348 |   111 |   372 |   132 |     601 |      0 |          1 |           1 | megan   |              | ../MAH00005.MP4 |
|        45 |   348 |   111 |   372 |   132 |     602 |      0 |          1 |           1 | megan   |              | ../MAH00005.MP4 |
|        45 |   348 |   111 |   372 |   132 |     603 |      0 |          1 |           1 | megan   |              | ../MAH00005.MP4 |
|        45 |   348 |   111 |   372 |   132 |     604 |      0 |          1 |           1 | megan   |              | ../MAH00005.MP4 |
|        45 |   348 |   111 |   372 |   132 |     605 |      0 |          1 |           1 | megan   |              | ../MAH00005.MP4 |
|        45 |   348 |   111 |   372 |   132 |     606 |      0 |          1 |           1 | megan   |              | ../MAH00005.MP4 |
|        45 |   348 |   111 |   372 |   132 |     607 |      0 |          1 |           1 | megan   |              | ../MAH00005.MP4 |
|        45 |   348 |   111 |   372 |   132 |     608 |      0 |          1 |           1 | megan   |              | ../MAH00005.MP4 |
|        45 |   348 |   111 |   372 |   132 |     609 |      0 |          1 |           1 | megan   |              | ../MAH00005.MP4 |


Target Schema:
| attributes          |
|:--------------------|
| directly_at_camera  |
| head_down           |
| normal              |
| partial_obstruction |

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