I have a pandas dataframe like below:
id val  date    period1 period2  period3  
 1  4   05/03     1         2         3  
 2  6   06/03     4         5         6  
 3  2   07/03     7         8         9  
 4  9   08/03     5         7         1  
I want to transform this from wide to long based on date and period like below:
id val  date  period  data 
 1  4   05/03  06/03    1  
               07/03    2 
               08/03    3  
 2  6   06/03  07/03    4 
               08/03    5   
               09/03    6  
 3  2   07/03  08/03    7     
               09/03    8     
               10/03    9  
 4  9   08/03  09/03    5      
               10/03    7     
               11/03    1  
That is the value of period will be the value of date+1month(year may also change) and so on, with its corresponding value coming in data column, while the rest of the dataframe remains the same.
How can I achieve this?
 
     
    