【发布时间】:2018-09-28 19:07:50
【问题描述】:
我已经开发了一个代码来读取所有特定文件并保存为 numpy 格式,例如
[[1 2]
[3 4]
[5 6]]
但是在我的代码中,numpy 数组返回空,谁能帮我解决它?谢谢。
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import GaussianNB
import numpy as np
list1=np.array([])
for x in range(101563,103807):
try:
x=str(x)
X=open("auto"+x)
count_vect = CountVectorizer()
X_train_counts = count_vect.fit_transform(X)
X=X_train_counts.shape
X=np.array([[X[0],X[1]]])
list1=np.append(list1,X, axis=0)
except:
y=x
【问题讨论】:
-
所以你的文件没有扩展名?
-
不……你指的是哪种扩展?
-
.txt或.csv什么的? -
不,我的文件没有任何扩展名
标签: python arrays numpy append concatenation