We have data like below

[![enter image description here](https://i.stack.imgur.com/66hLD.png)](https://i.stack.imgur.com/66hLD.png)

And I need output like

wanted data

[![enter image description here](https://i.stack.imgur.com/mTVre.png)](https://i.stack.imgur.com/mTVre.png)

Please help me out of this.