18 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
72
views
If I do a magic command, %run file, does that run the script as main? If so how do I get around this?
I have a .ipynb file and want to only import certain functions from it to another .ipynb file.
if I use:
if __name__ == "__main__":
would the script run what is under that if statement ...
0
votes
1
answer
73
views
Is `CPU times` of `%time` the total of User CPU time and System CPU time in IPython?
Running the code with the magic command %time in IPython got CPU times and Wall time as shown below:
In [1]: %time sum(range(1000000))
CPU times: total: 31.2 ms
Wall time: 26.7 ms
Out[1]: 499999500000
...
1
vote
3
answers
1k
views
Azure Synapse: How to get notebook magic command %pip to work in a pipeline
When running %pip install in my Synapse notebook manually, it works as intended, without any problems.
However, when I try to run that same notebook in a pipeline, I get:
{
"errorCode": &...
1
vote
2
answers
162
views
What magic command for appending code to existing file in jupyter notebooks
I am creating jupyter notebook tutorial to run streamlit app.
I use %%writefile dashboard_ui.py to write the cell code into the given file.
%%writefile app.py
import streamlit as st
st.title('Hello ...
1
vote
1
answer
620
views
How to allow %run magic command in Azure Databricks cluster?
I am currently trying to work through a Databricks course and am getting the following error stating that "Your administrator has only allowed sql and python commands on this cluster. This ...
0
votes
1
answer
71
views
Unable to run secondary notebook from Azure DevOps repo in Databricks due to 'file not found' error
I have my Azure DevOps repo cloned into Databricks. I'm trying to run the %run on a secondary notebook in the repo. When I attempt to execute the %run command on the secondary notebook, I consistently ...
1
vote
1
answer
1k
views
How to add same lines of code at the beginning of each cell in a Jupyter Notebook?
I would like to push my notebooks into GitLab without them showing the different outputs (3d plots, dataframes, etc...) in order to keep the size of those notebooks reasonable.
I had the following ...
0
votes
1
answer
303
views
I want to run magic command % somefile.py inside a jupyter notebook. However, this program requires variables from the main script
To clarify, somfile.py needs variables that are generated from main.ipynb. So, when I simply do %run somefile.py I get this error:
NameError: name 'viewer' is not defined
This viewer is defined in the ...
2
votes
2
answers
3k
views
Synapse : Execute the Magic Command (%run) Notebook from Pipeline
The magic commands work perfectly in Notebooks. However, While running the same notebook from the Synapse pipeline, it could not locate the notebook's path.
Appreciate your help
{
"errorCode&...
1
vote
1
answer
634
views
Use Built-in Magic Command to Run Script in Parent Directory
I don't know how to run the python scripts in parent directory using Jupyter Notebook's magic command %run script_name. I attempted to add the parent directory path into the sys.path as I did in the ...
6
votes
2
answers
9k
views
Azure databricks %run magic command unable to find file path
I have 2 notebooks under the root folder in my workspace. Calling one notebook from the other with %run magic cmd returns error saying file path not found. This is my command:
%run /Users/name@comp....
1
vote
1
answer
3k
views
How to pass a variable in a full cell magic command in Jupyter/Colab?
My code uses SQL to query a database hosted in BigQuery. Say I have a list of items stored in a variable:
list = ['a','b','c']
And I want to use that list as a parameter on a query like this:
%%...
1
vote
1
answer
479
views
Using rpy2 in jupyter notebook but there is no output. Error in withVisible({ : object 'returns' not found
the screenshot for jupyternotebook
I've successfully installed ryp2 using wheel. I'm using Python 3.7.6 and rpy2 2.9.5.
I can get the output from jupter notebook when running python code but it doesn'...
25
votes
2
answers
12k
views
Is %matplotlib inline still needed?
There are many resources that explains why %matplotlib inline is necessary to display plots inline. E.g. Purpose of %matplotlib inline. However, I feel that it is no longer necessary if we are using ...
41
votes
4
answers
74k
views
Line magic function `%%time` not found
Running this python scripta:
%%time
train_data = dt.fread('../input/prediction/train.csv').to_pandas()
The provided output returns this error:
UsageError: Line magic function %%time not found.
...