.csv
2D 배열 인 파일 에서 읽은 데이터 세트 가 있습니다.
이제 데이터 세트를 슬라이스하고 모든 목록의 첫 번째 요소를 가져 오려고합니다.
import numpy as np
rawData = []
with open(path) as file:
lines = csv.reader(file)
for line in lines:
rawData.append(line)
dataSet = rawData[0:10] # as the whole dataset is too large, I get the first ten rows to test
np.array(dataSet)
labels = dataSet[:,0]
내가 실행하면 :
print np.shape(dataSet)
>>>(10, 785)
나는 How to slice a 2D Python Array를 참조했습니다 . 그러나 여전히이 오류가 있습니다.
@jonrsharpe에게 감사드립니다. np.array(dataSet)
새 numpy 배열을 만들지 만 dataSet
. 그것은해야한다
result = np.array(dataSet)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다