Pandas DataFrame: sparse.from_spmatrix() function
DataFrame - sparse.from_spmatrix() function
The sparse-from_spmatrix() function is used to create a new DataFrame from a scipy sparse matrix.
Syntax:
classmethod sparse.from_spmatrix(data, index=None, columns=None)
Parameters:
Name | Description | Type / Default Value | Required / Optional |
---|---|---|---|
data | Must be convertible to csc format. | scipy.sparse.spmatrix | Required |
index, columns | Row and column labels to use for the resulting DataFrame. Defaults to a RangeIndex. | Index | Optional |
Returns: DataFrame
Each column of the DataFrame is stored as a SparseArray.
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame.hist() function
Next: DataFrame - sparse.to_dense() function
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework