textpack icon indicating copy to clipboard operation
textpack copied to clipboard

AttributeError: 'str' object has no attribute 'pop'

Open kishoremarodia opened this issue 5 years ago • 3 comments

File "C:\PythonWork\Project\fuzzywuzzy-ag.py", line 38, in tp.TextPack(df,'AG Name',match_threshold=0.7,ngram_remove=r'[,-./]', ngram_length=2)

File "C:\Users\XXX\AppData\Local\Continuum\anaconda3\lib\site-packages\textpack\tp.py", line 12, in init self._column = self._get_column(columns_to_group)

File "C:\Users\XXX\AppData\Local\Continuum\anaconda3\lib\site-packages\textpack\tp.py", line 21, in _get_column self.df['textpackGrouper'] = self.df[columns_to_group.pop(0)].astype(str).str.cat(self.df[columns_to_group].astype(str))

AttributeError: 'str' object has no attribute 'pop'

kishoremarodia avatar Dec 22 '20 16:12 kishoremarodia

Hello, this issue has been unanswered for a year almost. I a facing a similar issue. By any chance, please were you able to solve the issue?

Traceback` (most recent call last): File "G:/Shared drives/Dev/django-Project/scrap_api/textpack_test.py", line 85, in <module> rst = tp.TextPack(df, vals, match_threshold=0.75, ngram_remove=r'[,-./]', ngram_length=3) File "C:\Users\92\anaconda3\envs\djangoscrap\lib\site-packages\textpack\tp.py", line 12, in __init__ self._column = self._get_column(columns_to_group) File "C:\Users\92\anaconda3\envs\djangoscrap\lib\site-packages\textpack\tp.py", line 21, in _get_column self.df['textpackGrouper'] = self.df[columns_to_group.pop(0)].astype(str).str.cat(self.df[columns_to_group].astype(str)) AttributeError: 'numpy.ndarray' object has no attribute 'pop'

Thank you.

selfcontrol7 avatar Sep 07 '21 05:09 selfcontrol7

Hi, I ran into the same problem. I notice that you have tp.TextPack(df, vals, match_threshold=0.75, ngram_remove=r'[,-./]', ngram_length=3). The vals need to be a list for the .pop() method to work. You might wish to try tp.TextPack(df, ['vals'], match_threshold=0.75, ngram_remove=r'[,-./]', ngram_length=3) instead, if vals is the name of the column you wish to analyze.

liayin avatar Dec 07 '21 15:12 liayin

Hi, I ran into the same problem. I notice that you have tp.TextPack(df, vals, match_threshold=0.75, ngram_remove=r'[,-./]', ngram_length=3). The vals need to be a list for the .pop() method to work. You might wish to try tp.TextPack(df, ['vals'], match_threshold=0.75, ngram_remove=r'[,-./]', ngram_length=3) instead, if vals is the name of the column you wish to analyze.

Thank you for your suggestion. I will try it.

selfcontrol7 avatar Dec 08 '21 15:12 selfcontrol7