import pandas as pd
def tableRestore(df):
col = df.columns.tolist()[:-1]
letterContent = df[df.columns.tolist()[-1]]
data1 = df[col].fillna(method="ffill").iloc[0:list(df.index)[-1] + 1]
data1[df.columns.tolist()[-1]] = letterContent
print(data1)
openpath = r'D:\Users\Desktop\主板.xlsx'
df = pd.read_excel(openpath, sheet_name='主板', dtype='str')
tableRestore(df)
网友评论