question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BUG: max()/min() don't work on DataFrames constructed from scipy sparse matrix

See original GitHub issue

Example:

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:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
melkonyancommented, Apr 13, 2021

My bad, updated

0reactions
taytzehaocommented, Apr 22, 2021

Take

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found