java - IllegalArgumentException: '字段 "class" 不存在。\n可用字段: id, category'
问题描述
我使用的代码是
from pyspark.ml.feature import StringIndexer
indexer = StringIndexer(inputCol = 'class', outputCol = 'classIndex')
indexed = indexer.fit(df).transform(df)
indexed.show()
我收到以下错误
During handling of the above exception, another exception occurred:
IllegalArgumentException Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pyspark/sql/utils.py in deco(*a, **kw)
77 raise QueryExecutionException(s.split(': ', 1)[1], stackTrace)
78 if s.startswith('java.lang.IllegalArgumentException: '):
---> 79 raise IllegalArgumentException(s.split(': ', 1)[1], stackTrace)
80 raise
81 return deco
IllegalArgumentException: 'Field "class" does not exist.\nAvailable fields: id, category'
如何解决?
解决方案
推荐阅读
- javascript - JavaScript 箭头函数是如何工作的?
- json - 如何缩短类中变量的声明?
- mysql - Mysql group by 与 group by 相反
- excel - 将每个数据行保存在单独的新 CSV 文件中
- c++ - 共享预编译头文件
- java - 如何使用 Java 中的嵌套循环打印返回 2x2 和 3x3 矩阵中的字符串值的数学乘法表
- c# - ASP.NET Core 3.1 SHA512 和 SHA256Managed 有什么区别
- django - 无法重定向到类别列表 url - django
- php - 将 SQL 查询定义为变量时出现意外的 E0F
- java - 刷新 RecyclerView 中的数据并保持其滚动位置将用户带到活动的顶部