cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

2 REPLIES 2

-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

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now