筛选数据帧时出错(类型错误:类型比较无效)



我正在尝试根据列过滤掉数据帧,但出现错误TypeError: invalid type comparison

下面是我的数据帧视图:

id,name,start_date,new_customer
101,customer_1,2018-12-01,True
102,customer_2,2018-11-21,False
103,customer_3,2018-12-11,True
104,customer_4,2018-11-30,False

当我尝试做时出现错误

df = df['new_customer']=='True'

更新

df.dtypes

id - object
name - object
start_date - datetime64[ns]
new_customer - bool

使用不带撇号的True

df = df['new_customer'] == True

最新更新