BUG: max()/min() don't work on DataFrames constructed from scipy sparse matrix
See original GitHub issueExample:
import pandas as pd
from scipy import sparse as sc
import numpy as np
np.random.seed(42)
a = np.random.randint(0, 10, size=(200, 5))
a_sp = sc.coo_matrix(a)
a_sp_pd = pd.DataFrame.sparse.from_spmatrix(a_sp)
a_sp_pd.max()
Expected output:
0 9
1 9
2 9
3 9
4 9
dtype: int64
Actual output:
Series([], dtype: float64)
System info:
- numpy [required: >=1.17, installed: 1.20.2]
- scipy [required: >=0.19.1, installed: 1.6.2]
- pandas [required: >=1.0.0,<=1.1.4, installed: 1.2.4]
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
scipy.sparse.csr_matrix — SciPy v1.9.3 Manual
Sparse matrices can be used in arithmetic operations: they support addition, subtraction, multiplication, division, and matrix power. efficient arithmetic ...
Read more >Why does the pandas Dataframe version of a sparse matrix ...
The documentation says it accepts. X : {array-like, dataframe, sparse matrix}. That's sparse matrix , not sparse dataframe.
Read more >What's new in 1.4.0 (January 22, 2022) - Pandas
Implemented IntervalArray.min() and IntervalArray.max() , as a result of which min ... Performance improvement in constructing a DataFrame from array-like ...
Read more >Dask Best Practices - Dask documentation
The high level Dask collections (array, DataFrame, bag) include common operations ... data significantly df = df.compute() # continue on with pandas/NumPy ......
Read more >Data Manipulation - H2O.ai Documentation
A Scipy sparse matrix: create a matching sparse H2OFrame. ... H2OFrame(python_obj=python_lists).asfactor() >>> extra_levels = frame.append_levels(["A", ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

My bad, updated
Take