我试图删除表格的第一个标题行,即'表2 .......'。
我试过下面的代码
d1t2.columns = d1t2.iloc[0]
d1t2 = data1t2.reindex(d1t2.index.drop(0)).reset_index(drop=True)
d1t2.columns.name = None
d1t2
但结果是:表格的第二行,其中index=0
的行已被删除。
你很亲密:
d1t2.columns = d1t2.iloc[0]
d1t2.columns.name=None
d1t2.drop(0, axis=0, inplace=True)
但是,如果您从文件中读取d1t2
,最好跳过第一行。