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:ย 

How to use a Dataframe created in one Notebook from Another, without writing it anywhere ?

Amodak91
New Contributor II

I have a large Notebook and want to divide it into multiple Notebooks and use Databricks jobs to run parallelly. However, one of the notebook is using a dataframe from one of the notebooks, so it has to be run downstream of the other ones. Now, since it is using the values from previous dataframe, how can I use the dataframe from the upstream Notebooks without writing it to a file or Unity Catalog. Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

menotron
Valued Contributor

Hi @Amodak91, you could use the %run magic command from within the downstream notebook and call the upstream notebook thus having it run in the same context and have all it's variables accessible including the dataframe without needing to persist it. 

Alternatively you could register a temp view on the dataframe and call the downstream notebook using the dbutils.notebook.run() method.

You could read more about this here and decide what suits better.

View solution in original post

1 REPLY 1

menotron
Valued Contributor

Hi @Amodak91, you could use the %run magic command from within the downstream notebook and call the upstream notebook thus having it run in the same context and have all it's variables accessible including the dataframe without needing to persist it. 

Alternatively you could register a temp view on the dataframe and call the downstream notebook using the dbutils.notebook.run() method.

You could read more about this here and decide what suits better.

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