I have a dataframe like this
Date A B Stat
1-jan M a start
1-jan K 0 0
1-jan T b start
1-jan N a end
1-jan W 0 0
1-jan R b end
Actually, a and b represents activities that starts with start and ends with end value of Stat column. The Act column represents activity number. I want to create a new dataframe based on B and Stat columns so that my output will be:
Date A B Stat Act
1-jan M a start 1
1-jan K 0 0 1
1-jan T b start 1
1-jan N a end 1
1-jan T b start 2
1-jan N a end 2
1-jan W 0 0 2
1-jan R b end 2
The Act column represents activity number. Any help will be really appreciated.