Skip to main content
Solved

pivot table long to wide not working with AttributePivoter


mzuer
Contributor
Forum|alt.badge.img+5
  • Contributor

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 

Best answer by takashi

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”.

 

View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

takashi
Evangelist
  • Best Answer
  • June 21, 2025

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”.

 


geomancer
Evangelist
Forum|alt.badge.img+54
  • Evangelist
  • June 23, 2025

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

Don't forget to use an AttributeExposer afterwards.

 


mzuer
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • June 28, 2025

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...)

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings