Python 从excel表格中删除缺少数据的数据

Python 从excel表格中删除缺少数据的数据,python,pandas,Python,Pandas,我正在尝试连接我从excel中读取的许多表,并使用pandas进行数据透视。除了最后的数据帧GRL缺少最后两列之外,下面的代码工作得非常好。这些列对应于输入excel文件中的列,其中有几个空单元格作为第一个条目。我曾尝试在数据子集和测试数据上使用concat,它似乎有效,但不适用于整个数据集。似乎pd.concat没有在datetime索引上使用union,该索引中的列以缺少的数据开头 有人能在这里发现一个明显的错误吗?谢谢 path = 'C:\\dr\\' WQ_file = 'File.x

我正在尝试连接我从excel中读取的许多表,并使用pandas进行数据透视。除了最后的数据帧GRL缺少最后两列之外,下面的代码工作得非常好。这些列对应于输入excel文件中的列,其中有几个空单元格作为第一个条目。我曾尝试在数据子集和测试数据上使用concat,它似乎有效,但不适用于整个数据集。似乎pd.concat没有在datetime索引上使用union,该索引中的列以缺少的数据开头

有人能在这里发现一个明显的错误吗?谢谢

path = 'C:\\dr\\'
WQ_file = 'File.xlsx'

xl = pd.ExcelFile(path + WQ_file)
sheet_names = xl.sheet_names

GRL = pd.read_excel(path + WQ_file, sheetname = sheet_names[0], parse_cols = 15, index_col = 0, na_values = ['', 'na'])
GRL = GRL.stack(dropna=False).reorder_levels([1,0]).sortlevel(0)
GRL.name = sheet_names[0]

for n in sheet_names[1:-1]:
    df1 = pd.read_excel(path + WQ_file, sheetname = n, parse_cols = 15, index_col = 0, na_values = ['', 'na'])
    df1 = df1.stack(dropna=False).reorder_levels([1,0]).sortlevel(0)
    df1.name = n
    GRL = pd.concat([GRL, df1], axis = 1)
GRL.columns.name = 'Locations'
GRL

这确实有效。所以没有问题。谢谢