import pandas as pd import numpy as np df = pd.DataFrame(np.arange(12).reshape(3,4), columns=['A', 'B', 'C', 'D']) print("df",df) # df.drop([-1],inplace=True) df.drop([len(df)-1],inplace=True) print("df",df)
注意不要用df.drop([-1],inplace=True),这个写法不对
参考:https://blog.csdn.net/nini3816/article/details/102939424