I would like to save a big matrix as a .csv
file. However, from numpy's documentation I tried the following:
training_matrix = dict_vect.fit_transform(training_data_2_dict)
csv_matrix = np.savetxt("foo.csv", training_matrix, delimiter=",")
This is the shape of the matrix: (878049, 413439)
and this is the exception:
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
Any idea of how to save the matrix in a csv file?.