arrayname.astype(' bool')vs dtype =' bool'

时间:2018-06-16 16:15:55

标签: python arrays numpy

我有一个简单的问题:我在创建数组时尝试使用方法in (ispace d1)和参数arrayname.astype('bool')来尝试将dtype = 'bool'类型转换为int类型。我是这样做的:

bool

输出结果为:

booleanarray = np.array(range(10), dtype = 'bool')
print booleanarray 

现在,使用[False True True True True True True True True True]

arrayname.astype('bool')

输出变为:

my_array = np.array(range(10))
my_array.astype('bool')
print my_array

为什么第二个输出不像第一个?为什么没有[0 1 2 3 4 5 6 7 8 9] 将my_array中的元素转换为bool?

谢谢!

0 个答案:

没有答案
相关问题