How come pandas pd.SparseDataFrame never completes for large data sets?

大兔子大兔子 提交于 2019-12-08 04:54:46

问题


I have the following python3 code that doesn't seem to complete. Is there an estimate for how long this takes? I would like to be able to use sparsedataframes because a large number of the elements are 0 value.

>>> s_matrix
<12000x61190 sparse matrix of type '<class 'numpy.float32'>' with 1577553 stored elements in Compressed Sparse Row format>

>>> sdf = pd.SparseDataFrame(s_matrix)

This has been running for hours and still hasn't completed. Similarly, I was able to load the 1.3GB data set into a dataframe, but the sdf = df.to_sparse() never completed and I ended up aborting the run.

Any help for speeding up the conversion to SparseDataFrame would be appreciated.

来源:https://stackoverflow.com/questions/46750202/how-come-pandas-pd-sparsedataframe-never-completes-for-large-data-sets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!