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

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group