天天看點

Python中drop函數删除指定行報錯?

Python中drop函數删除指定行報錯?

我想删除最後一行,依次試驗圖中紅框内的三行代碼都報錯,代碼如下:import pandas as pdimport numpy as npdf = pd.DataFrame(np.arange(16).reshape(4, 4), index=list("abcd"), columns=list("wxyz"))print(df)# df = df.drop([len(df) - 1], inplace=True)# df.drop([len(df) - 1], axis=0,inplace=True)df.drop(index=(len(df) - 1), axis=0,inplace=True)print(df)

Python中drop函數删除指定行報錯?