I am working with a data set where in I need to find average of two rows and replace the two rows by average.
the following is the data set in which I want to find average value for each day for a given week and sensor.Once i figure this out I can use transpose/stack functions to obtain desired output.Any help is appreciated.
| Sensor | Week | DoW | Value |
| A | 1 | | 0.25 |
| A | 2 | | 0.33 |
| A | 3 | | 0.76 |
| A | 4 | Sun(D) | 0.21 |
| A | | Sun(N) | 0.75 |
| A | | Mon(D) | 0.33 |
| A | | Mon(N) | 0.34 |
| B | 1 | | 0.6 |
| B | 2 | | 0.82 |
| B | 3 | | 0.55 |
| B | 4 | Sun(D) | 0.4 |
| B | | Sun(N) | 0.22 |
| B | | Mon(D) | 0.91 |
| B | | Mon(N) | 0.98 |
| C | 1 | | 0.25 |
| C | 2 | | 0.35 |
| C | 3 | | 0.76 |
| C | 4 | Sun(D) | 0.21 |
| C | | Sun(N) | 0.75 |
| C | | Mon(D) | 0.33 |
| C | | Mon(N) | 0.34 |
The expected output is -
| Sensor | Week1 | Week2 | Week3 | Week4.Sun | Week4.Mon |
| A | 0.25 | 0.33 | 0.76 | 0.48 | 0.34 |
| B | 0.6 | 0.82 | 0.55 | 0.31 | 0.95 |
| C | 0.25 | 0.35 | 0.76 | 0.48 | 0.34 |