我有一个数据框“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/