Discover the winners & finalists of the 2022 Dataiku Frontrunner Awards!READ THEIR USE CASES

Transpose columns into rows

Level 2
Transpose columns into rows

Dear dataiku community,

question from a non-developer: there is a processor to transform rows into columns. The thing is that I would like to do the opposite, as openrefine allows to do it. I have not found a processsor that fit that need.


F. Clavert

0 Kudos
3 Replies

@fclavert , I will admit that I don't know of a simple way to do this with a visual recipe (though one may exist). While you wait for others to respond here is a very simple python recipe that should give you what you are after. 

# -*- coding: utf-8 -*-
import dataiku

# Read recipe inputs
input_dataset = dataiku.Dataset("input_dataset")
input_dataset_df = input_dataset.get_dataframe()

# Write recipe outputs
transposed = dataiku.Dataset("transposed")

Here, "input_dataset" should be changed to match the name of your actual dataset. You might want to try with a small-ish dataset before throwing a large dataset at it.


Level 2

Thanks a lot. I will try. I think I nevertheless found a visual recipe that could work (pivot). I will try and, if I succeed, will come back here.


0 Kudos

@fclavert so first off, I feel like a complete dolt. Not having used the Transpose recipe I jumped straight to finding a solution. It just dawned on me that transpose rows to columns should be the same as columns to row. (transpose means to make rows columns and vice-versa) 

Using the Transpose calculation is not particularly intuitive (at least to me). But I found the following would allow me to transpose my data.

1. Use the "Transpose Rows into Columns" but Specify a NONEXISTENT column (something like fake_column). That gives me a warning but will make all the columns rows and vice versa.

2. Delete and rename columns as you see fit.






0 Kudos