Pandas sparse dataFrame to sparse matrix, without generating a dense matrix in memory
问题 Is there a way to convert from a pandas.SparseDataFrame to scipy.sparse.csr_matrix , without generating a dense matrix in memory? scipy.sparse.csr_matrix(df.values) doesn't work as it generates a dense matrix which is cast to the csr_matrix . Thanks in advance! 回答1: Pandas docs talks about an experimental conversion to scipy sparse, SparseSeries.to_coo: http://pandas-docs.github.io/pandas-docs-travis/sparse.html#interaction-with-scipy-sparse ================ edit - this is a special function