Reshaping an array to data.frame
Answer recommended by R Language Collective
Answer recommended by R Language Collective
Using clues from @chrisb’s answer, this gave me exactly what I was after: df2.reset_index(inplace=True) which gives: id Cost1 Cost2 Cost3 Value1 Value2 Value3 1 124 214 1234 12 23 15 2 1324 0 234 45 0 34 and in case of multiple index columns, this post explains it well. just to be complete, here is … Read more
Cross-tabs or pivot tables is the answer. From there you can SELECT FROM … INSERT INTO … or create a VIEW from the single SELECT. Something like: SELECT country, MAX( IF( key=’President’, value, NULL ) ) AS President, MAX( IF( key=’Currency’, value, NULL ) ) AS Currency, … FROM table GROUP BY country;