Hi,
I am trying to read data from excel file based on a particular pattern.
I want my Dataframe to be created from the row where Account Number is present. It should be making that row a header and data afterwards.
How can i achieve the same without reading the file twice.
I am able to achieve the same by using below code, but it reads the file twice. Thus, becomes time consuming.
data = pd.read_excel(r'C:\Users\Dell\Desktop\data.xlsx')
num = 0
for index,row in data.iterrows():
if 'Account Number' in row.values:
print(index,type(row))
num = index
break
data = pd.read_excel(r'C:\Users\Dell\Desktop\data.xlsx',header=num+1)
data = data.dropna(axis=0, how='all')
data.xlsx (8.4 KB)