Posted on:

18 Mar 2024

0

Value Error when plotting unigrams

Hi, so I've been coding along this entire lecture and I've encountered an error I can't seem to resolve. 

For this peace of code: 

sns.barplot(x = unigrams.values[:10], 
            y = unigrams.index[:10], 
            orient = 'h',
            palette=[default_plot_colour])\
.set(title='Most Common Unigrams After Preprocessing')

I'm getting this error message:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-127-8bc68529eea9> in <cell line: 1>()
----> 1 sns.barplot(x = unigrams.values[:10], 
      2             y = unigrams.index[:10],
      3             orient = 'h',
      4             palette=[default_plot_colour])\
      5 .set(title='Most Common Unigrams After Preprocessing')

7 frames
/usr/local/lib/python3.10/dist-packages/pandas/core/indexes/multi.py in _set_names(self, names, level, validate)
   1465         # Don't allow a single string for names in a MultiIndex
   1466         if names is not None and not is_list_like(names):
-> 1467             raise ValueError("Names should be list-like for a MultiIndex")
   1468         names = list(names)
   1469 

ValueError: Names should be list-like for a MultiIndex

I tried to find a solution, and even copied this part of code from the Git repository, and the problem still excists. Everything I've done to this point is identical to this lecture. Also, I've tried downloading the ipynb file from Git, it has the same error. What should I do?

0 answers ( 0 marked as helpful)

Submit an answer