简体   繁体   English

如何将一个数据块笔记本导入另一个?

[英]How to import one databricks notebook into another?

I have a python notebook A in Azure Databricks having import statement as below:我在 Azure Databricks 中有一个 python 笔记本 A,其导入语句如下:

import xyz, datetime, ...

I have another notebook xyz being imported in notebook A as shown in above code.我在笔记本 A 中导入了另一个笔记本 xyz,如上面的代码所示。 When I run notebook A, it throws the following error:当我运行笔记本 A 时,它抛出以下错误:

ImportError: No module named xyz  

Both notebooks are in the same workspace directory.两个笔记本都在同一个工作区目录中。 Can anyone help in resolving this?任何人都可以帮助解决这个问题吗?

The only way to import notebooks is by using the run command: 导入笔记本的唯一方法是使用run命令:

%run /Shared/MyNotebook

or relative path: 或相对路径:

%run ./MyNotebook

More details: https://docs.azuredatabricks.net/user-guide/notebooks/notebook-workflows.html 更多细节: https//docs.azuredatabricks.net/user-guide/notebooks/notebook-workflows.html

To get the result back as a DataFrame from different notebook in Databricks we can do as below.要从 Databricks 中的不同笔记本中将结果作为 DataFrame 返回,我们可以执行以下操作。

noebook1笔记本1

def func1(arg): def func1(arg):

df=df.transfomationlogic
return df

notbook2笔记本2

%run path-of-notebook1 %run path-of-notebook1

df=func1( dfinput ) df=func1( dfinput )

Here the dfinput is a df you are passing and you will get the transformed df back from func1.这里dfinput是您正在传递的 df,您将从 func1 获取转换后的 df。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将一个 Databricks Notebook 导入另一个错误 - Importing one Databricks Notebook into another error 如何将本地模块导入 azure databricks 笔记本? - How to import a local module into azure databricks notebook? 如何将一个 Jupyter 笔记本导入另一个 - How can I import one Jupyter notebook into another 如何导入数据砖笔记本中轮文件中的方法? - How to import a method which is in wheel file in databricks notebook? 如何将 jupyter notebook 导入另一个 jupyter notebook? - How to import jupyter notebook to another jupyter notebook? 如何将参数发送到数据块笔记本? - how to send parameters to databricks notebook? 如何在不将其转换为 csv 的情况下将 PySpark dataframe 从一台 Jupyter 笔记本导入到另一台笔记本? - How to import a PySpark dataframe from one Jupyter Notebook to another without converting it to csv? 如何在 DataBricks 中导入“displayHTML”? - How to import `displayHTML` in DataBricks? 在 DataBricks 的一个特定笔记本中连接 Blob 容器 - Connecting with Blob Container in one specific notebook in DataBricks 在 Databricks python notebook 中,如何导入与 file2 位于不同目录中的 file1 对象? - In Databricks python notebook, how to import a file1 objects resides in different directory than the file2?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM