long_to_periods function

Transform a data frame from long format to period format