0

I have such a dataframe:

dataframe

On the variables column, there are 5 variables, namely Electric power consumption, Literacy rate, Logistics, Health, and Taxes. I would like to create a column for each variable. Their values should come from the value column. In the end, the dataframe should look like below:

  cname     | year | electric_consumption | literacy rate | logistics | health | taxes
afghanistan | 1960 |       564            |       73      |      64   |   363  |  563
afghanistan | 1961 |       256            |       45      |      64   |   465  |  546
afghanistan | 1962 |       ###            |       ##      |      ##   |   ###  |  ###
     .          .           .                      .              .        .       .
     .          .           .                      .              .        .       .
     .          .           .                      .              .        .       .
zimbabwe    | 2010 |       ###            |       ##      |      ##   |   ###  |  ###
Emin
  • 306
  • 2
  • 11
  • dont reopen the same question if it was closed. it was closed for a reason. did you even read the related question? – luigigi Oct 29 '21 at 09:46
  • @luigigi - some another question was closed? – jezrael Oct 29 '21 at 09:48
  • Yes, I have read the related question. I have tried many ways of solving this but unfortunately couldn't do it. Instead of spending a day on a basic problem, I think it is better to ask it. – Emin Oct 29 '21 at 09:48
  • Why are you closing the question? – Emin Oct 29 '21 at 09:49
  • @jezrael didnt you closed the same question like 5 minutes ago? I think i saw it earlier – luigigi Oct 29 '21 at 09:50
  • I deleted that question and asked it in a different way. – Emin Oct 29 '21 at 09:51
  • thats what I meant – luigigi Oct 29 '21 at 09:51
  • Dude why I can't ask a question? It is not duplicate anymore – Emin Oct 29 '21 at 09:52
  • @Emin - Hi. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael Oct 29 '21 at 09:57
  • [Please don't post images of code/data (or links to them)](http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question) – jezrael Oct 29 '21 at 09:57

0 Answers0