Skip to main content

Dear all,

 

I am trying to do something that seems very simple :I have a table that has 3 columns “id”, “category”, “value”  and I would like to reshape it in wide format “id”, “category.A”, “category.B”, etc. (in R, it would be reshape(dt, direction=”wide”, idvar=”id”, timevar=”category”)

I have tried the AttributePivoter with the settings : Group rows=id, group columns =category, attribute to analyze = value

but it does not work, in the output I still get the 3 columns id, category, value with missing values everywhere in the category and value columns

 

what am I doing wrong ? would another transformer do the job ?

 

thanks in advance 

Hi ​@mzuer ,

I think you can use AttributeCreator to create a new attribute whose name is equal to the value of “category” and assign the value of “value” to the new attribute, and accumulate the features group by id with Aggregator. Then, expose the new attribute names with AttributeExposer if necessary.
See the screenshot to learn more. Assuming "category.A" or "category.B" is the value of the attribute called "category".

 

You can also use BulkAttributeRenamer instead of AttributeCreator to replace the attribute name “value” with the value of the attribute “category”.

 


Neat trick, I never knew the BulkAttributeRenamer could be used like this.

Don't forget to use an AttributeExposer afterwards.

 


sorry for the delay in replying, @takashi thanks a lot for detailed explanation, it works perfectly :-)

it's a pity, however, that there's no possibility of making a fully “automatic” transposition (you have to manually select the attributes to be exposed, and if the data changes, you run the risk of forgetting to expose a category...)