I am using databricks repos
I have two files, My function in a file called func.py in another folder called folder1
def lower_events(df):
return df.withColumn("event",f.lower(f.col("event")))
My main notebook in which I am calling the lower_events
import pyspark.sql.functions as f
from pyspark.sql.functions import udf, col, lower
import sys
sys.path.append("..")
from folder1 import func
df_clean = func.lower_events(df)
This returns an error
NameError: name 'f' is not defined
But this is working
def lower_events(df):
import pyspark.sql.functions as f
from pyspark.sql.functions import col, when
return df.withColumn("event",f.lower(f.col("event")))