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 ...
随机推荐
- LeetCode_278. First Bad Version
278. First Bad Version Easy You are a product manager and currently leading a team to develop a new ...
- win8(x64)下,重新安装delphi 2007时出现“Invalid Serial Number”,如何解决?
1)在添加删除程序里卸载delphi 2007 2)删除C:\ProgramData\CodeGear 3)删除C:\Program Files (x86)CodeGear 4)删除d:\Progra ...
- box-sizing:border-box 将元素的内边距和边框都设定在宽高内计算
http://www.w3school.com.cn/cssref/pr_box-sizing.asp box-sizing: content-box|border-box|inherit; 值 描述 ...
- Jmeter学习——测试计划元件【转】
1. Test Plan (测试计划) 用来描述一个性能测试,包含与本次性能测试所有相关的功能.也就说本次性能测试的所有内容是于基于一个计划的. 下面看一下一个计划下面都有哪些主要的功能模块(右键单击 ...
- 高级UI-CardView
CardView是在Android 5.0推出的新控件,为了兼容之前的版本,将其放在了v7包里面,在现在扁平化设计潮流的驱使下,越来越多的软件使用到了CardView这一控件,那么这篇文章就来看看Ca ...
- Intellij IDEA 打包jar的多种方式
IDEA打包jar包的多种方式 用IDEA自带的打包形式 用Maven插件maven-shade-plugin打包 用Maven插件maven-assembly-plugin打包 1.view-> ...
- hdoj4099(字典树+高精度)
题目链接:https://vjudge.net/problem/HDU-4099 题意:给T组询问,每个询问为一个字符串(长度<=40),求以该字符串为开始的fibonacci数列的第一个元素的 ...
- 将linux的root用户的家目录由/root切换为/home/root
步骤1,先以root登录,然后创建目录/home/root步骤2,vi /etc/passwd里root用户的家目录为/home/root:步骤3,cp -rf /root/ /home/将原来的ro ...
- WiFi、ZigBee、BLE用哪个?
小米是这么选的: 1) 插电的设备,用WiFi: 2) 需要和手机交互的,用BLE: 3) 传感器用ZigBee. WIFI,WIFI是目前应用最广泛的无线通信技术,传输距离在100-300M,速率可 ...
- synchronized的不足与redis分布式锁的使用
这里是一个简单模拟秒杀的逻辑,stock和orders为两个Map,分别模拟库存表和订单表 public void orderProductMockDiffUser(String productId) ...