Pandas 用 df.drop 删除行不起作用 [英] Pandas deleting row with df.drop doesn't work
本文介绍了Pandas 用 df.drop 删除行不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个这样的 DataFrame(第一列是 index
(786...) 和第二个 day
(25...) 和 Rainfall amount
为空):
I have a DataFrame like this (first column is index
(786...) and second day
(25...) and Rainfall amount
is empty):
Day Rainfall amount (millimetres)
786 25
787 26
788 27
789 28
790 29
791 1
792 2
793 3
794 4
795 5
我想删除第 790 行.我用 df.drop 尝试了很多东西,但没有发生任何事情.
and I want to delete the row 790. I tried so many things with df.drop but nothin happend.
希望你能帮我.
推荐答案
同时丢弃新的 DataFrame 返回.如果要将更改应用于当前 DataFrame,则必须指定 inplace
参数.
While dropping new DataFrame returns. If you want to apply changes to the current DataFrame you have to specify inplace
parameter.
选项 1
分配回 df
-
df = df.drop(790)
<小时>
选项 2
就地参数 -
df.drop(790, inplace=True)
这篇关于Pandas 用 df.drop 删除行不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文