“ final_counts”类型为“ scipy.sparse.csr.csr_matrix”类,形状为(364171,115281)
“ new_column”的类型为“类'numpy.ndarray'”,并且形状为(364171,)。在这里,我不确定为什么列数为空。
使用下面的代码向“ final_counts”添加新列“ new_column”
merged_data = scipy.sparse.hstack((final_counts, new_column))
以上代码为您提供以下错误帮助。
仅供参考-在很小的数据集上使用相同的代码即可。
File "C:\Python34\lib\site-packages\scipy\sparse\construct.py", line 464, in hstack
return bmat([blocks], format=format, dtype=dtype)
File "C:\Python34\lib\site-packages\scipy\sparse\construct.py", line 585, in bmat
raise ValueError(msg)
ValueError: blocks[0,:] has incompatible row dimensions. Got blocks[0,1].shape[0] == 1, expected 364171.