Recipe 7 – transposing rows and columns

Sometimes data is not arranged into rows and columns the way you like. Indeed, there are different ways of arranging what belongs where, and the choices depend on the situation. In the Powerhouse Museum dataset, for instance, there are separate columns for several dimensions: Height, Width, Depth, Diameter, and Weight. However, not many objects have data for these columns, so the cost of maintaining them might be high with respect to the value they add. An alternative would be to transform these five columns into two columns: one that contains the name of the dimension (for instance, Height or Weight) and another that contains the measurement (for instance, 35mm or 2kg).

What we want to do here is to transpose ...

Get Using OpenRefine now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.