我想将一个大矩阵保存为.csv
文件。但是,从numpy's documentation我尝试了以下内容:
training_matrix = dict_vect.fit_transform(training_data_2_dict)
csv_matrix = np.savetxt("foo.csv", training_matrix, delimiter=",")
这是矩阵的形状:(878049, 413439)
,这是例外:
Traceback (most recent call last):
File "/Users/user/PycharmProjects/kaggle/modeling_the_problem.py", line 55, in <module>
training_matrix)
File "/usr/local/lib/python2.7/site-packages/numpy/lib/npyio.py", line 1044, in savetxt
ncol = X.shape[1]
IndexError: tuple index out of range
如何在csv文件中保存矩阵?