Hi,
I have excel file with merged columns as below:
Group is merged for Name & Item column, Sub_valid is a merged column for Value, Color, Status.
When I read using:
The column above Item is "Unnamed0" & Color column & Status column are "Unnamed1", Unnamed2",
But I want:
I use below code but it needs to do multiple time:
but I want to replace if header starts with: Unnamed"
I have excel file with merged columns as below:
1 2 3 4 |
Category Group Sub_valid Name Item Value Color Status Group1 VGT Power 0 VGT Power BHA Voltage 1 BHA Voltage |
When I read using:
1 2 |
import pandas as pd df = pd.read_excel( 'D:PythonCodes\mergedinput.xlsx' ,sheetname = 'Sheet1' ) |
But I want:
1 2 3 4 |
Category Group Group Sub_valid Sub_valid Sub_valid Name Item Value Color Status Group1 VGT Power 0 VGT Power BHA Voltage 1 BHA Voltage |
1 |
df.rename(columns = { '*Unnamed: 1' : 'nan' }, inplace = True ) |