-1

I have a csv file that has 480 columns and one row which has the header's name. I want to get the excel column name for a specific header. for e.g-

var1 var2 event5 event8 media5 retail6 event9 var10

Let's say, I need to locate the excel column namefor retail6(F Column in Excel). what is the best and easiest way of doing that?

output should be- var1 A var2 B event5 C and so on

1 Answers1

0

I think this answer might be the one you are looking for: stackoverflow.com/a/31328974/13734132

new_header = df.iloc[0] #grab the first row for the header
df = df[1:] #take the data less the header row
df.columns = new_header #set the header row as the df header
  • Thanks, but I do not want to replace the headers. I want to get the excel column name of a particular header, for eg : Var1 is under Excel Column "A", var2 is under Excel Column "B" and so on. If I want to locate the excel column name for media5 header, it should return Excel Column name : E – Inquisitive Jan 17 '22 at 04:38