Why does my Notebook fails if I try to load a function from another Notebook in Repos in Databricks

shubhamb
New Contributor III

My function in func.py

def lower_events(df):
 return df.withColumn("event",f.lower(f.col("event")))

My main notebook

import pyspark.sql.functions as f
from pyspark.sql.functions import udf, col, lower
import sys
 
sys.path.append("..")
from folder.func.  import   lower_events
#from folder  import   func
 
df_clean = lower_events(df)

I am getting this error

NameError: name 'f' is not defined

-werners-
Esteemed Contributor III

@Shubham Biswas​, so func.py is a plain Python file, not a Databricks notebook?

Can you also check the following topic?

https://community.databricks.com/s/question/0D53f00001mUyh2CAC/limitations-with-udfs-wrapping-module...

shubhamb
New Contributor III