[英]How to drop a row based on a condition in pandas with string converted to integer for comparison
[英]How to drop a row based on the condition of a column in pandas?
'CENTER'
列2
。作品:
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'), :]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.