博客
关于我
ValueError: Length of values does not match length of index
阅读量:689 次
发布时间:2019-03-17

本文共 552 字,大约阅读时间需要 1 分钟。

今日有个学生截图问了我一个问题,我擦扎心啊。扎心的不是这个问题有多低级,而是他没有解决问题的能力。虽然是个别问题,但依然是我的错。

ValueError: Length of values does not match length of index

翻译一下:

ValueError: value的长度不匹配index的长度

很明显的错误:

学生源代码是:

data["评价编号"] = np.where(data[data["评价"] == "好评"], 1, 0)

我让他输出了一下data[data[“评价”] == “好评”]的结果:

学生的截图如下:
在这里插入图片描述
经过一番对Series属性的提醒,他的问题终于解决了:在次引导学生学会使用手中工具解决问题,哎,只能多引导,谁让人家是上帝呢!!!
随即发给我解决之后的代码,问题解决:

data["评价编号"] = np.where(data["评价"].values == "好评", 1, 0)

在这里插入图片描述

之后我又提示了一个上周我们拓展过的API

preprocession模块中的LabelEncoder
在这里插入图片描述
感慨:

虽然学生的问题解决了,但是个人还是比较感慨,学生独立解决问题的能力,属实是有待挖掘,希望我的担心全是多余的吧。同时也祝愿本班学生可以100%就业。

转载地址:http://dhchz.baihongyu.com/

你可能感兴趣的文章
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named 'pandads'
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No qualifying bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs<?>‘ available
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>