Pregunta de entrevista de FactSet

How to sort data wide to long and long to wide? (R & Python)