- くだすれPython(超初心者用) その42【Ruby禁止】
424 :デフォルトの名無しさん[]:2019/03/31(日) 10:06:21.56 ID:hLnMjByF - >>> np.linspace(0, 10, 11)
array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]) >>> np.linspace(0, 10, 11) * .5 array([ 0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5, 5. ]) >>> int(np.linspace(0, 10, 11) * .5) TypeError: only length-1 arrays can be converted to Python scalars >>> np.int(np.linspace(0, 10, 11) * .5) TypeError: only length-1 arrays can be converted to Python scalars >>> list(map(int, np.linspace(0, 10, 11) * .5)) [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5] >>> np.array(list(map(int, np.linspace(0, 10, 11) * .5))) array([0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5]) これは map 使わないとだめ? なんかもっと良い方法ある気がする 👀 Rock54: Caution(BBR-MD5:1341adc37120578f18dba9451e6c8c3b)
|