python - 'function' 对象在 Python 中不可下标
问题描述
我尝试使用此代码:
def tw_list(text):
tw_list['text'] = tw_list['text'].str.lower()
print('Case Folding Result : \n')
print(tw_list['text'].head(5))
print('\n\n\n')
但是当我运行它时,我得到了错误:
Case Folding Result :
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-27-c3ee7c744c13> in <module>
6
7 print('Case Folding Result : \n')
----> 8 print(tw_list['texts'].head(5))
9 print('\n\n\n')
TypeError: 'function' object is not subscriptable
我不知道为什么,有人可以帮助我吗?
解决方案
tw_list 是您的函数的名称。 您正在尝试以 dict 的形式访问该函数。因此它会引发错误
推荐阅读
- amazon-web-services - AWS CloudWatch Logs Insight 查询以使用 ALB 日志找出服务可用性
- javascript - 没有看到播种数据库后所需的 sequelize 模型属性
- postman - Postman:如何为特定环境设置授权类型?
- python - 如何在所有列上应用爆炸
- python - Python - 按属性汇总数据框的值
- c# - 测试字符串末尾的正则表达式和 \n EOL
- php - 继承类中静态属性的层次结构
- python - 从 soup.find 中选择文本
- python-3.x - 希望以粗体突出显示值,但该功能未按预期工作
- c# - 在监视器之间移动应用程序 - C#