Pyspark:AssertionError: dataType should be DataType
1. schema参数,AssertionError: dataType should be DataType
# AssertionError: dataType should be DataType
schema = StructType([
# true代表不为空
StructField("col_1", StringType, True),
StructField("col_2", StringType, True),
StructField("col_3", StringType, True),
]
)
#原因:StringType等后面没有加括号“()”
#修改为:
schema = StructType([
# true代表不为空
StructField("col_1", StringType(), True),
StructField("col_2", StringType(), True),
StructField("col_3", StringType(), True),
]
)
2. pyspark目前的数据类型有:
NullType、StringType、BinaryType、BooleanType、DateType、TimestampType、DecimalType、DoubleType、FloatType、ByteType、IntegerType、LongType、ShortType、ArrayType、MapType、StructType(StructField)等,要根据情况使用,注意可能的溢出问题。
其中大佬总结的对应python数据类型如下:
| NullType | None |
| StringType | basestring |
| BinaryType | bytearray |
| BooleanType | bool |
| DateType | datetime.date |
| TimestampType | datetime.datetime |
| DecimalType | decimal.Decimal |
| DoubleType | float(double precision floats) |
| FloatType | float(single precision floats) |
| ByteType | int(a signed integer) |
| IntegerType | int(a signed 32-bit integer) |
| LongType | long(a signed 64-bit integer) |
| ShortType | int(a signed 16-bit integer) |
参考:https://www.cnblogs.com/yurunmiao/p/4923694.html
Pyspark:AssertionError: dataType should be DataType的更多相关文章
- 运行gulp项目报错:AssertionError: Task function must be specified。
一.问题描述: gulp项目在本地windows 10机器上跑没有任何问题,但是放在centos 7虚拟机上跑报错:AssertionError: Task function must be spec ...
- atom markdown报错:AssertionError: html-pdf: Failed to load PhantomJS module.
今天安装markdown-pdf之后运行的时候报错: AssertionError: html-pdf: Failed to load PhantomJS module. You have to se ...
- 【Flask】报错解决方法:AssertionError: View function mapping is overwriting an existing endpoint function: main.user
运行Flask时出现了一个错误, AssertionError: View function mapping is overwriting an existing endpoint function: ...
- Python错误:AssertionError: group argument must be None for now
运行多线程出现的错误 调试了很久,最后发先 __init__ 写错了,修改后后,运行正确.
- CORS基础要点:关于dataType、contentType、withCredentials
事实上,面试时我喜欢问跨域,因为多数开发者都知道它并且常用,而我希望能从面试者的回答中知道他在这个问题的深入程度,进一步看看面试者研究问题的思维方式及钻研精神,然而确实难到了很多人,当然这也不是面试通 ...
- 表单校验之datatype
凡要验证格式的元素均需绑定datatype属性,datatype可选值内置有10类,用来指定不同的验证格式. 如果还不能满足您的验证需求,可以传入自定义datatype,自定义datatype是一个非 ...
- [转载]表单校验之datatype
凡要验证格式的元素均需绑定datatype属性,datatype可选值内置有10类,用来指定不同的验证格式. 如果还不能满足您的验证需求,可以传入自定义datatype,自定义datatype是一个非 ...
- HTML Input 表单校验之datatype
凡要验证格式的元素均需绑定datatype属性,datatype可选值内置有10类,用来指定不同的验证格式. 如果还不能满足您的验证需求,可以传入自定义datatype,自定义datatype是一个非 ...
- AJAX中的dataType
参考ajax的api文档 dataType的类型:String ajax中的dataType的属性: text:返回纯文本字符串 json:返回json数据 jsonp:jsonp格式(我没用过) h ...
随机推荐
- 【serviceaccount 和 clusterrolebinding】
kubectl get clusterrolebinding kubectl create clusterrolebinding suosheng-rebinding --clusterrole=cl ...
- antd一些问题
1.去掉button光晕 用ant design中的Button的时候,每次点击都会在视图button上添加一个属性ant-click-animating-without-extra-node这个属性 ...
- mongodb4.0 安装
下载: wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.9.tgz 解压缩 tar -zxvf mongodb-linux ...
- IDEA 创建JAVA Maven Web 工程
转载自https://www.cnblogs.com/1314wamm/p/7475771.html 步骤一:首先先创建一个project,上次我说过了创建一个project就是一个工作空间,在这里就 ...
- C罗是你人生中最好的健身教练和精神导师
C罗又进球了,两场小组赛包揽全队4粒进球,一己之力帮助葡萄牙取得1胜1平,掌握出线主动权.此前三届世界杯金靴分别只有6球.5球.5球进账,C罗如果能延续火爆状态,金靴唾手可得. 之前三届世界杯,C罗7 ...
- php 文字转换成拼音
<?php //中文字转拼音 $d=array( array("a",-20319), array("ai",-20317), array("a ...
- Redis的安装(windows)
一.安装redis windows版本的下载在https://github.com/MicrosoftArchive/redis/tags msi是安装版,zip的解压就能用.建议下msi的. 下载挺 ...
- 10分钟搭建一个小型网页(python django)(hello world!)
10分钟搭建一个小型网页(python django)(hello world!) 1.安装django pip install django 安装成功后,在Scripts目录下存在django-ad ...
- PAT(B) 1093 字符串A+B(Java和C)
题目链接:1093 字符串A+B (20 point(s)) 题目描述 给定两个字符串 A 和 B,本题要求你输出 A+B,即两个字符串的并集.要求先输出 A,再输出 B,但重复的字符必须被剔除. 输 ...
- 使用uiautomator 截图
1)PC与移动设备建立连接. 2)找到ADB的安装路径,双击启动uiautomator. 路径:D:\ProgramFiles\adt-bundle-windows-x86_64-20140702\a ...