美文网首页Python编程技巧
004 Pandas 的DataFrame操作技巧

004 Pandas 的DataFrame操作技巧

作者: Jame_Y | 来源:发表于2019-07-13 20:17 被阅读0次

1 基于行索引,删除特定行

a = pd.DataFrame({1: [1,2,3], 
                  2: [4,5,6]
                 })
print(a)

>>>    1  2
>>> 0  1  4
>>> 1  2  5
>>> 2  3  6


# 此时若想要删除索引为1的列,可用如下操作:
a.drop(index=[1], inplace=True)
print(a)

>>>    1  2
>>> 0  1  4
>>> 2  3  6

相关文章

网友评论

    本文标题:004 Pandas 的DataFrame操作技巧

    本文链接:https://www.haomeiwen.com/subject/xkomkctx.html