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:
| UNIT   | DATEn    | TIMEn    |   ENTRIESn |   EXITSn |   ENTRIESn_hourly |   EXITSn_hourly | datetime            |   hour |   day_week |   weekday | station      |   latitude |   longitude | conds            |   fog |   precipi |   pressurei |   rain |   tempi |   wspdi |   meanprecipi |   meanpressurei |   meantempi |   meanwspdi |   weather_lat |   weather_lon |
|:-------|:---------|:---------|-----------:|---------:|------------------:|----------------:|:--------------------|-------:|-----------:|----------:|:-------------|-----------:|------------:|:-----------------|------:|----------:|------------:|-------:|--------:|--------:|--------------:|----------------:|------------:|------------:|--------------:|--------------:|
| R266   | 05-15-11 | 20:00:00 |   14886742 | 12915507 |               506 |             608 | 2011-05-15 20:00:00 |     20 |          6 |         0 | HALSEY ST    |    40.6956 |    -73.904  | Mostly Cloudy    |     0 |         0 |       29.6  |      1 |    62.6 |    10.4 |    0.0133333  |         29.635  |     61.7    |     7.68333 |       40.7053 |      -73.9028 |
| R215   | 05-17-11 | 08:00:00 |   21854600 | 20155614 |              1410 |             388 | 2011-05-17 08:00:00 |      8 |          1 |         1 | 86 ST        |    40.6227 |    -74.0284 | Rain             |     0 |         0 |       29.93 |      1 |    53.6 |    17.3 |    0.105      |         29.93   |     55.45   |    13.2667  |       40.6358 |      -73.9608 |
| R246   | 05-18-11 | 00:00:00 |   15462060 |  4633921 |               245 |             101 | 2011-05-18 00:00:00 |      0 |          2 |         1 | PROSPECT AVE |    40.6654 |    -73.9929 | Light Rain       |     0 |         0 |       29.97 |      1 |    53.6 |    17.3 |    0.036      |         29.974  |     59.02   |    10.14    |       40.6886 |      -73.9913 |
| R227   | 05-02-11 | 20:00:00 |   19561725 | 12625278 |              4089 |             598 | 2011-05-02 20:00:00 |     20 |          0 |         1 | RECTOR ST    |    40.7072 |    -74.0134 | Overcast         |     0 |         0 |       30.15 |      0 |    57.9 |     4.6 |    0          |         30.235  |     55.35   |     5.96667 |       40.708  |      -74.0149 |
| R341   | 05-14-11 | 12:00:00 |    7869057 |  1161831 |               649 |              61 | 2011-05-14 12:00:00 |     12 |          5 |         0 | 75 AVE       |    40.7185 |    -73.8372 | Overcast         |     0 |         0 |       29.87 |      0 |    63   |    10.4 |    0          |         29.8517 |     59.3333 |     8.45    |       40.7182 |      -73.839  |
| R253   | 05-19-11 | 00:00:00 |   12460016 |  9164000 |               276 |             460 | 2011-05-19 00:00:00 |      0 |          3 |         1 | 174-175 ST   |    40.8459 |    -73.9101 | Overcast         |     0 |         0 |       29.94 |      0 |    62.6 |     9.2 |    0          |         29.9783 |     62.3667 |     9.41667 |       40.858  |      -73.912  |
| R203   | 05-16-11 | 04:00:00 |   36169459 | 24334621 |                 0 |              57 | 2011-05-16 04:00:00 |      4 |          0 |         1 | 23 ST-6 AVE  |    40.7429 |    -73.9928 | Overcast         |     0 |         0 |       29.62 |      1 |    62.6 |     6.9 |    0.00333333 |         29.715  |     58.2833 |     9.23333 |       40.7421 |      -73.9987 |
| R309   | 05-01-11 | 20:00:00 |    9243349 |  5889800 |               596 |             663 | 2011-05-01 20:00:00 |     20 |          6 |         0 | 176 ST       |    40.8486 |    -73.9125 | Mostly Cloudy    |     0 |         0 |       30.28 |      0 |    52   |    10.4 |    0          |         30.265  |     55.8167 |     8.08333 |       40.858  |      -73.912  |
| R215   | 05-20-11 | 04:00:00 |   35425708 | 28406799 |                85 |             218 | 2011-05-20 04:00:00 |      4 |          4 |         1 | 86 ST        |    40.6227 |    -74.0284 | Clear            |     0 |         0 |       29.97 |      1 |    57.2 |     0   |    0.00333333 |         29.9617 |     60.0833 |     0       |       40.6358 |      -73.9608 |
| R253   | 05-26-11 | 00:00:00 |   12489927 |  9183842 |               375 |             547 | 2011-05-26 00:00:00 |      0 |          3 |         1 | 174-175 ST   |    40.8459 |    -73.9101 | Scattered Clouds |     0 |         0 |       29.94 |      0 |    66   |     9.2 |    0          |         29.9117 |     67.4667 |     9.6     |       40.858  |      -73.912  |


Target Schema:
|   day_week |    ENTRIESn |      EXITSn |   ENTRIESn_hourly |   EXITSn_hourly |     hour |   weekday |   latitude |   longitude |        fog |     precipi |   pressurei |      rain |   tempi |   wspdi |   meanprecipi |   meanpressurei |   meantempi |   meanwspdi |   weather_lat |   weather_lon |
|-----------:|------------:|------------:|------------------:|----------------:|---------:|----------:|-----------:|------------:|-----------:|------------:|------------:|----------:|--------:|--------:|--------------:|----------------:|------------:|------------:|--------------:|--------------:|
|          0 | 4.13343e+07 | 2.85851e+07 |           2586.12 |         1856.92 |  9.98794 |         1 |    40.74   |    -73.9394 | 0          | 0.0006058   |     29.9929 | 0.220787  | 62.5369 | 8.04045 |   0.0006058   |         29.9929 |     62.5381 |     8.04084 |       40.7412 |      -73.9401 |
|          1 | 4.09867e+07 | 2.84488e+07 |           3105.15 |         2198.63 |  9.97535 |         1 |    40.7403 |    -73.9393 | 0.00687876 | 0.013511    |     29.9789 | 0.200344  | 65.7483 | 8.44285 |   0.013511    |         29.9789 |     65.7483 |     8.44285 |       40.7415 |      -73.94   |
|          2 | 3.99657e+07 | 2.77586e+07 |           3268.89 |         2325.64 | 10.0446  |         1 |    40.7398 |    -73.9399 | 0.0380256  | 0.0107569   |     29.9734 | 0.502377  | 61.4127 | 7.87477 |   0.0107569   |         29.9734 |     61.4127 |     7.87477 |       40.7409 |      -73.9406 |
|          3 | 4.01734e+07 | 2.78085e+07 |           3291.34 |         2318.08 | 10.0261  |         1 |    40.74   |    -73.94   | 0.0043573  | 0.00159041  |     29.9777 | 0.157226  | 62.0456 | 7.66696 |   0.00159041  |         29.9777 |     62.0456 |     7.66696 |       40.7411 |      -73.9406 |
|          4 | 4.01812e+07 | 2.78151e+07 |           3217.65 |         2279.29 | 10.0489  |         1 |    40.7403 |    -73.9397 | 0          | 0.000853081 |     29.9455 | 0.249727  | 62.6092 | 4.85027 |   0.000853081 |         29.9455 |     62.6092 |     4.85027 |       40.7414 |      -73.9403 |
|          5 | 4.07619e+07 | 2.82133e+07 |           1931.51 |         1442.67 | 10.0863  |         0 |    40.7398 |    -73.9401 | 0          | 0           |     29.9128 | 0.0678716 | 64.5091 | 5.41848 |   0           |         29.9128 |     64.5091 |     5.41848 |       40.7409 |      -73.9407 |
|          6 | 4.1124e+07  | 2.84264e+07 |           1469.67 |         1118.84 | 10.0663  |         0 |    40.7395 |    -73.9398 | 0.0220006  | 0.00307715  |     30.001  | 0.200352  | 62.1916 | 6.30689 |   0.00307715  |         30.001  |     62.1916 |     6.30689 |       40.7407 |      -73.9405 |

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