A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sparse.from_spmatrix.html below:

pandas.DataFrame.sparse.from_spmatrix — pandas 2.3.1 documentation

pandas.DataFrame.sparse.from_spmatrix#
classmethod DataFrame.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 a arrays.SparseArray.

Examples

>>> import scipy.sparse
>>> mat = scipy.sparse.eye(3, dtype=float)
>>> pd.DataFrame.sparse.from_spmatrix(mat)
     0    1    2
0  1.0    0    0
1    0  1.0    0
2    0    0  1.0

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4