小之一 2022-03-28 10:20 采纳率: 50%
浏览 4028
已结题

AttributeError: 'numpy.ndarray' object has no attribute 'split'

问题遇到的现象和发生背景

AttributeError: 'numpy.ndarray' object has no attribute 'split'

问题相关代码,请勿粘贴截图

max_document_length = max([len(x.split(" ")) for x in x_data])
vocab_processor = learn.preprocessing.VocabularyProcessor(max_document_length)

运行结果及报错内容

AttributeError: 'numpy.ndarray' object has no attribute 'split'

我的解答思路和尝试过的方法
我想要达到的结果
  • 写回答

2条回答 默认 最新

  • hellobigorange 人工智能领域新星创作者 2022-03-28 11:08
    关注

    max([len(x.split(" ")) for x in x_data]),你的x的数据类型可能是numpy,她是没有.split属性的,你把x转换为字符串,如str(x)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • 於黾 2022-03-28 10:26
    关注

    x_data是什么,是frame吗
    报错说x是numpy.ndarray,
    而你把x当做字符串在用了

    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月6日
  • 已采纳回答 3月29日
  • 创建了问题 3月28日

悬赏问题

  • ¥15 端口转发器解析失败不知道电脑设置了啥
  • ¥15 Latex算法流程图行号自定义
  • ¥15 关于#python#的问题:我在自己的电脑上运行起来总是报错,希望能给我一个详细的教程,(开发工具-github)
  • ¥40 基于51单片机实现球赛计分器功能
  • ¥15 cs2游戏画面卡住,应用程序sid与指挥者sid不匹配
  • ¥15 实验七:Pandas要有实验截图和代码
  • ¥15 TypeError: Make sure that the iterable only contains strings.
  • ¥35 电脑放图书馆,这是被黑了吗
  • ¥15 等高线中数据取消科学计数法
  • ¥15 Qt播放10路ffmpeg 视频流