Python Word Vect numpy 数组,在保存到 csv 时给出维度错误,预期为 1D 或 2D 数组,得到的是 0D 数组

Python Word Vect numpy array, on saving to csv gave error on dimension , Expected 1D or 2D array, got 0D array instead

保存 wordVect 出错,

from sklearn.feature_extraction.text import CountVectorizer
corpus = [
    'This is the first document.',
    'This document is the second document.',
    'And this is the third one.',
    'Is this the first document?',
]
vectorizer = CountVectorizer(ngram_range=()
X = vectorizer.fit_transform(corpus)

# Save The Vector 
np.savetxt('logvect.csv', X, delimiter=',')

遇到错误

----> 1 np.savetxt('logvect.csv', X, 分隔符=',')

   1375         if X.ndim == 0 or X.ndim > 2:
   1376             raise ValueError(
-> 1377                 "Expected 1D or 2D array, got %dD array instead" % X.ndim)
   1378         elif X.ndim == 1:
   1379             # Common case -- 1d array of numbers

ValueError: Expected 1D or 2D array, got 0D array instead

X.toarray() # 丢失

np.savetxt('logvect.csv', X.toarray(), delimiter=',')