xlsx表格还原pandas操作
2021-12-07 本文已影响0人
月夜星空下
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)