Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
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.
Best,
F. Clavert
@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")
transposed.write_with_schema(input_dataset_df.transpose())
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.
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.
Best.
@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.
-Tim