-1

I have some transformation task.

I have to read a csv file with following data:

Name,Age,2020,2021,2022
ABCD,11,0.11,1,2.1

And the aforementioned dataframe has to be converted to the following:

Name,Age,Year,Value
ABCD,11,2020,0.11
ABCD,11,2021,1

Note: There can be N number of years as column names and all years have to be transposed. Will regex be a correct approach?

samkart
  • 6,007
  • 2
  • 14
  • 29
  • 1
    Does this answer your question? [How to melt Spark DataFrame?](https://stackoverflow.com/questions/41670103/how-to-melt-spark-dataframe) – samkart Oct 10 '22 at 17:19

1 Answers1

0

Use pandas or numpy to modify .csv files.