我在用 df=df.drop(index='historical book')
删除所有包含 historical book
.
第一行是标题
id name book subject amount
1 name1 historical book 6
2 name2 literature book 9
3 name3 historical book 4
我收到一个错误信息,说这是 not found in axis
. 你知道为什么吗?
这样做就可以了。
print(df[~df['subject'].str.contains('historical book')])
id name book subject amount
1 2 name2 literature book 9