Skip to content

Textrank example fails: 'numpy.ndarray' object has no attribute 'loc' #133

@freddyheppell

Description

@freddyheppell

Thank you for submitting a bug report!

Steps to Reproduce

Run the demo_pytextrank.py file. It will crash with:

   '<b>%s</b> TextRank score rank: %s/%s' % (cat, term_ranks.loc[term, cat], corpus.get_num_metadata())
AttributeError: 'numpy.ndarray' object has no attribute 'loc'

This appears to be due to a mistake in the code (or some change in a library that's broken it), as term_ranks is a numpy array, not a Pandas dataframe.

Expected behavior

The example should run.

Environment

  • Scattertext version (e.g., 0.0.2.75): 0.1.19
  • Have I tried running this on the latest version of Scattertext? N/A, is latest version
  • OS (e.g., Linux): macOS
  • How you installed Scattertext (conda, pip, source): Pip
  • Build command you used (if compiling from source): N/A
  • Python version: 3.9.16
  • Version of dependencies: Numpy 1.25.2, Pandas 2.0.3, pytextrank 3.2.5
  • Any other relevant information:

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions