내가되는 DTYPE했다 :numpy에서 ndarray의 dtype을 맞춤 1로 변경하는 방법은 무엇입니까?
mytype = np.dtype([('a',np.uint8), ('b',np.uint8), ('c',np.uint8)])
그래서 DTYPE 사용하여 어레이 :
test1 = np.zeros(3, dtype=mytype)
TEST1은 :
array([(0, 0, 0), (0, 0, 0), (0, 0, 0)],
dtype=[('a', '|u1'), ('b', '|u1'), ('c', '|u1')])
은 이제 TEST2가를 :
test2 = np.array([[1,2,3], [4,5,6], [7,8,9]])
ㅁㅁ
array([[(1, 1, 1), (2, 2, 2), (3, 3, 3)],
[(4, 4, 4), (5, 5, 5), (6, 6, 6)],
[(7, 7, 7), (8, 8, 8), (9, 9, 9)]],
dtype=[('a', '|u1'), ('b', '|u1'), ('c', '|u1')])
나는 결과가되고 싶어요 :
array([(1, 2, 3), (4, 5, 6), (7, 8, 9)],
dtype=[('a', '|u1'), ('b', '|u1'), ('c', '|u1')])
어떤 방법이 있나요 내가 test2.astype(mytype)
를 사용하는 도중, 결과는 내가되고 싶은 것이 아니다? 감사.