I am trying to store scipy.sparse.csr.csr_matrix of shape (1482535, 67826) into a dataframe but I am getting an error as below. I am running on Google Cloud Platform with 4CPU's , and 208 GB memory. I can't increase my memory more. How can I solve this issue? Any suggestions are appreciated.
type(x_train_bow_name)`
scipy.sparse.csr.csr_matrix
data1 = pd.DataFrame(x_train_bow_name.toarray())`
-----------------------------------------------------------------
----------
MemoryError Traceback (most recent
call
last)
<ipython-input-16-283fa4dd2dd6> in <module>
----> 1 data1 = pd.DataFrame(x_train_bow_name.toarray())
/usr/local/lib/python3.5/dist-
packages/scipy/sparse/compressed.py in toarray(self, order, out)
1022 if out is None and order is None:
1023 order = self._swap('cf')[0]
-> 1024 out = self._process_toarray_args(order, out)
1025 if not (out.flags.c_contiguous or
out.flags.f_contiguous):
1026 raise ValueError('Output array must be C or
F contiguous')
/usr/local/lib/python3.5/dist-packages/scipy/sparse/base.py in
_process_toarray_args(self, order, out)
1184 return out
1185 else:
-> 1186 return np.zeros(self.shape,
dtype=self.dtype, order=order)
1187
1188
MemoryError: Unable to allocate array with shape (1482535, 67826)
and data type int64