【发布时间】:2019-01-25 17:16:47
【问题描述】:
我多次尝试运行以下代码。输出有时是“真”(我所期望的),有时是“假”。崇高有什么问题吗?我用 jupyter notebook 对其进行了测试,输出始终为“True”。
import pandas as pd
df = pd.DataFrame({'a':[1,2,3]})
print(df.dtypes.isin(['int64']))
如果我打印 df.dtypes,输出总是'int64'。
print(df.dtypes)
>> a int64
dtype: object
Python 版本:anaconda python3.6。崇高版本:3.1.1。熊猫版本:0.23.4
【问题讨论】:
-
@Chris 感谢您的评论。将 'int64' 更改为 np.dtype('int64') 似乎有所帮助。但在我的 jupyter notebook 测试中,isin(['int64']) 的返回值确实是“真”。我不知道为什么。可能是因为numpy的版本不同。
标签: python pandas sublimetext3