This answer包含了一种非常优雅的方式,可以在一行中设置所有类型的pandas列: # convert column "a" to int64 dtype and "b" to complextype
df = df.astype({"a": int, "b": complex}) 我开始认为,不幸的是,它的应用有限,您将不得不使用其他各种方法来转换列类型,或早或晚,跨越许多行。我测试了'category',它起作用了,所以它将接受像int或<
我得到以下错误TypeError: '<' not supported between instances of 'int' and 'datetime.date'
我的代码是np.where((Manual_Dialling['Text_Date'] > Manual_Dialling['set_date']) & (Manual_Dialling['Text_Date