I would like some advice on how to split a excel header cell using python, pandas, or openpyxl (what I'm currently trying to learn. This is something that I've done in excel/vba using text-to-columns. But I'm coming up with errors while trying to get this to work with Python... I have a dataframe and use pd.read_excel to the file. I can print(df.columns.tolist()) to see my columns. I would like a piece of code to place each test# into it's own column.
These are all headers within a dataframe.
This is what I'd like to accomplish.
I had tried this method believing 5 is the column I need.
df.columns = df.columns[5].split(',')
I have also tried this method. Here I was thinking I had to list out what i wanted in the first statement and the name of the E1 cell currently. The delimiter is ',' a comma between each test#.
df[['test1','test2','test3','test4','test5',test6','test7','test8','test9']] =
df.test1,test2,test3,test4,test5,test6,test7,test8,test9.str.split(",",expand=True,)
Any help would be appreciated. Thanks
This is an excel version of the dataframe version already posted above.