Transforming data with a partial transpose - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Transforming data with a partial transpose (/thread-11644.html) |
Transforming data with a partial transpose - DivyaDS - Jul-19-2018 Hello, I have a requirement of transposing my data partially Here is the sample Input & output I am looking for.. Pid Mkdn Date Clr Sls$ Mkdn $ 1 14-Apr 100 10 1 22-Apr 200 20 1 28-Apr 300 30 2 14-Apr 100 10 2 22-Apr 200 20 2 28-Apr 300 30 3 14-Apr 100 10 3 22-Apr 200 20 3 28-Apr 300 30 Pid Mkdn Date Metric Name Value 1 14/4 Clr Sls$ 100 1 22/4 Clr Sls$ 200 1 28/4 Clr Sls$ 300 1 14/4 Mkdn$ 10 1 22/4 Mkdn$ 20 1 28/4 Mkdn$ 30 2 14/4 Clr Sls$ 100 2 22/4 Clr Sls$ 200 2 28/4 Clr Sls$ 300 2 14/4 Mkdn$ 10 2 22/4 Mkdn$ 20 2 28/4 Mkdn$ 30 3 14/4 Clr Sls$ 100 3 22/4 Clr Sls$ 200 3 28/4 Clr Sls$ 300 3 14/4 Mkdn$ 10 3 22/4 Mkdn$ 20 3 28/4 Mkdn$ 30 RE: Transforming data with a partial transpose - Larz60+ - Jul-19-2018 what have you tried, please show code RE: Transforming data with a partial transpose - DivyaDS - Jul-19-2018 I am new to Python, so I just have thought process.. I was just thinking.. extract each column ,make it repeat the number of times as per the product of (count of dates & number of metrics-> in this case 2 metrics, Clr Sls$, Mkdn$) for a particular Pid, then repeat the dates similarly, and then integrate the columns or something.. Please guide me on the thought process.. May be not code for now.. |