python - pandas,分割或划分(减去)数据框

标签 python pandas indexing split divide

我有一个数据框“moment_f”。 我必须从 moment_f 中删除一些包含名称“AH”的行。 但是我不会删除每个“AH”行,所以我创建了一个新的数据框 包含我要删除的“AH”。

ah1 = moment_f[moment_f["TextGridLabel"] == "AH"]
ah_d = ah1.iloc[::2] 
# got the odd rows of "AH" which is what I need to get rid of from the original dataframe "moment_f". 

所以现在我想从数据帧“moment_f”中删除数据帧“ah_d”。

串联的反义词是什么? 我尝试过删除、拆分等,但不起作用。

最佳答案

IIUC 需要:

df = moment_f[~moment_f.index.isin(ah_d.index)]

关于python - pandas,分割或划分(减去)数据框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52830239/

相关文章:

python - Pandas 提高效率

sql - 选择Oracle中某个类型的所有索引

python - 在 scikit-learn 中使用 ExtraTreesClassifier 时出错

python - 当我调用 update_idletasks() 时,Tkinter 有时会卡住

python - 编辑 DataFrame 中的值

list - 在 Pandas Dataframe 中查找空或 NaN 条目

datetime - pandas 日期时间切片 : junkdf. ix ['2015-08-03' :'2015-08-06' ] 不起作用

python - XGBoost 使用 sklearn API 获取 predict_contrib?

python - 将 python 中的数据框 reshape 为 3D

Python 单词和短语的共现矩阵