Skip to content

Fix pandas Series AttributeError when indexing sparse matrices#97

Open
alpkaancelik wants to merge 1 commit into
snap-stanford:masterfrom
alpkaancelik:fix-pandas-series-indexing
Open

Fix pandas Series AttributeError when indexing sparse matrices#97
alpkaancelik wants to merge 1 commit into
snap-stanford:masterfrom
alpkaancelik:fix-pandas-series-indexing

Conversation

@alpkaancelik

Copy link
Copy Markdown

Convert pandas Series boolean masks to numpy arrays before using them to index scipy sparse matrices. This fixes the AttributeError: 'Series' object has no attribute 'nonzero' that occurs with newer pandas versions.

Changes:

  • Line 87: Fixed ctrl_expression calculation
  • Line 93: Fixed ctrl_adata assignment in init
  • Line 321: Fixed ctrl_adata assignment in predict method

This ensures compatibility with pandas >= 2.0 where Series no longer has the nonzero() method that scipy sparse matrix indexing expects.

Convert pandas Series boolean masks to numpy arrays before using them
to index scipy sparse matrices. This fixes the AttributeError: 'Series'
object has no attribute 'nonzero' that occurs with newer pandas versions.

Changes:
- Line 87: Fixed ctrl_expression calculation
- Line 93: Fixed ctrl_adata assignment in __init__
- Line 321: Fixed ctrl_adata assignment in predict method

This ensures compatibility with pandas >= 2.0 where Series no longer
has the nonzero() method that scipy sparse matrix indexing expects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant