numpy.core._exceptions.UFuncTypeError:ufunc'subtract'did not contain a loop with signature matching types(dtype('<U4'),dtype('<U4'))-->dtype('<U4')
sql="""
select * from sss;
"""
df=spark.sql(sql)
后续出上面错误,是因为用到的2个列的数据类型不同,这种读取方式改变某一列数据类型的方式如下:
from pyspark.sql.functions import col
df=df.withColumn("score",col("score").cast('integer'))
#上面作用是把“score”列数据类型改为“integer”类型