【问题标题】:how to deal with TypeError: polarity_scores() missing 1 required positional argument: 'text'如何处理 TypeError:polarity_scores() 缺少 1 个必需的位置参数:'text'
【发布时间】:2021-09-02 16:31:51
【问题描述】:

当我跑步时

df=[]
DataTab['scores'] = DataTab['headline_text'].apply(lambda x: vader.polarity_scores(x))
DataTab.head()

我遇到了这个错误

*---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-248-157ec346f35d> in <module>
      1 df=[]
----> 2 DataTab['scores'] = DataTab['headline_text'].apply(lambda x: vader.polarity_scores(x))
      3 DataTab.head()
~\Anaconda3\lib\site-packages\pandas\core\series.py in apply(self, func, convert_dtype, args, **kwds)
   4040             else:
   4041                 values = self.astype(object).values
-> 4042                 mapped = lib.map_infer(values, f, convert=convert_dtype)
   4043 
   4044         if len(mapped) and isinstance(mapped[0], Series):
pandas\_libs\lib.pyx in pandas._libs.lib.map_infer()
<ipython-input-248-157ec346f35d> in <lambda>(x)
      1 df=[]
----> 2 DataTab['scores'] = DataTab['headline_text'].apply(lambda x: vader.polarity_scores(x))
      3 DataTab.head()
TypeError: polarity_scores() missing 1 required positional argument: 'text'*

请帮助我 我应该安装或更改什么

【问题讨论】:

  • 您必须出示您的数据样本,以便我们重现您的问题。
  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: python typeerror vader


【解决方案1】:

谢谢。通过初始化变量然后在 lambda 中使用它来修复它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-14
    • 2014-09-13
    • 1970-01-01
    • 1970-01-01
    • 2019-10-10
    • 2017-03-27
    • 2019-11-12
    相关资源
    最近更新 更多