简体   繁体   English

Azure Databricks 和 pyspark - 子串错误

[英]Azure Databricks & pyspark - substring errors

Getting two errors with my Databricks Spark script with the following line:使用以下行在我的 Databricks Spark 脚本中出现两个错误:

df = spark.createDataFrame(pdDf).withColumn('month', substring(col('dt'), 0, 7))

The first one:第一个:

AttributeError: 'Series' object has no attribute 'substr'

and

NameError: name 'substr' is not defined

I wonder what I am doing wrong...我想知道我做错了什么...

原来我没有导入pyspark.sql.functions

from pyspark.sql.functions import *

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM