Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.DataFrame.sparse.from_spmatrix#

classmethodDataFrame.sparse.from_spmatrix(data,index=None,columns=None)[source]#

Create a new DataFrame from a scipy sparse matrix.

Parameters:
datascipy.sparse.spmatrix

Must be convertible to csc format.

index, columnsIndex, optional

Row and column labels to use for the resulting DataFrame.Defaults to a RangeIndex.

Returns:
DataFrame

Each column of the DataFrame is stored as aarrays.SparseArray.

Examples

>>>importscipy.sparse>>>mat=scipy.sparse.eye(3,dtype=float)>>>pd.DataFrame.sparse.from_spmatrix(mat)     0    1    20  1.0    0    01    0  1.0    02    0    0  1.0

[8]ページ先頭

©2009-2025 Movatter.jp