如何根据pandas中某列的条件删除一行?

How to drop a row based on the condition of a column in pandas?

作品:

BuildingNameContains_center = dframe[dframe[2].str.contains('CENTER')]

输出作品:

BuildingNameContains_center

产生错误:

dframe.drop(BuildingNameContains_center, inplace= True)

KeyError: '[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23\n 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41] not found in axis'

IIUC,而不是对数据帧进行子集化,然后尝试删除行。只需将原始选择的倒数子集化即可。

dframe = dframe.loc[~dframe[2].str.contains('CENTER'), :]