Pandas:删除最后一行

解决方案

代码

image

效果展示

image

完整代码

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)

参考链接

https://codeantenna.com/a/bmg9WarstT

posted @ 2022-06-22 14:06  胸怀丶若谷  阅读(1114)  评论(0编辑  收藏  举报