To utilize IPython.notebook.kernel.execute in Azure Databricks, follow these steps:
Open the Databricks notebook in which you want to use IPython.notebook.kernel.execute.
Click on the "Settings" tab on the top right-hand side of the notebook.
Scroll down to find "Advanced Options" and click on it.
In "Advanced Options," you will see an input box named "Initialization Script." Add the following code in the input box:
if get_ipython().__class__.__name__ == 'ZMQInteractiveShell':
from IPython import get_ipython
get_ipython().kernel.do_execute('%alias_magic --line shell /bin/bash')
This code will enable the Magic alias shell command inside the notebook.
Now, add your own code in a new cell and write the following line of code in it:
IPython.notebook.kernel.execute("your code here")
This line of code will execute your code using the notebook kernel.
Finally, you can run the cell to test the execution of your code.
Note: Make sure that you have installed and imported IPython in your notebook.
Asked: 2021-10-30 11:00:00 +0000
Seen: 12 times
Last updated: May 11 '22