Look at using the sparse array capabilities in scipy:
scipy.sparse documentation .
The scipy.sparse library has a set of examples and tutorials:
Exceptional Lectures: Sparse Matrices in SciPy
This can help you solve memory problems, as well as make things faster.
To create an empty sparse array with values ββat specific positions, as you requested in your comment:
Is there a way to create an empty array with values ββin certain positions, for example: last_array [211147] [9], but would it remain empty everywhere?
from scipy.sparse import * values = [42] row_ind = [211147] col_ind = [9] last_array = csc_matrix((values, (row_ind, col_ind)), shape=(211148,211148)) print(last_array[211147,9])
source share