I'm want have autocomplete in jupyter notebook. I want the feacture give by the
%config IPCompleter.greedy=True
command but I don't write/run any time this line. There is a method for include it in setting of jupyter?
Related
I was trying to using !date to print date-related information in jupyter notebook, but it seems that it just hang around there without running, what might be reason. I am using Anaconda virtual environment on windows.
In IPython syntax, the exclamation mark (!) allows users to run shell commands from inside a Jupyter Notebook code cell.
If you are on Windows, date will show the system data and allows you to set a new one. This doesn't make much sense from inside Jupyter Notebooks.
If you want to see the current date and time in IPython, instead use
import time
time.strftime("%c")
I have the following code in jupyter notebook, using python. I get the error when I run it saying "FileNotFoundError" but all of the files are in a labeled folder.
file_path=os.path.dirname(os.path.abspath("__file__"))
df=pd.read_csv(file_path+ "\\score_NFL.csv",encoding="utf-8")
teams=pd.read_csv(file_path+"\\nfl_teams.csv",encoding='utf-8')
games_elo=pd.read_csv(file_path+"\\nfl_games3.csv",encoding="utf-8")
games_elo18=pd.read_csv(file_path + "\\nfl_games_2019_1.csv",encoding="utf-8")
You don't want to have quotes around __file__. It refers to a special object created when running a script or using an imported module (see the answers here for details). Your first line should be
file_path=os.path.dirname(os.path.abspath(__file__))
However, you state in your question that you're attempting to run this code in a Jupyter notebook. In an instance like this, similar to using the REPL on the command line, __file__ is not defined because you're not running the script from a file - it's interactive.
This method will work if you save your code in a .py file and run it from the directory containing your CSV files. At the same time, if you're running the code from the same directory, you don't need to go through all the hassle of creating a full absolute path to the CSVs, you can simply use
df = pd.read_csv("score_NFL.csv", encoding="utf-8")
for example.
As the title suggests, I'm looking to find the run time for my entire Jupyter notebook.
Perhaps something like %%time for the entire notebook. Have tried looking around for a solution, but I can't seem to find one that doesn't require me to define a function.
Any help would be appreciated, thank you guys!
You can install and enable the Execute Time extension mentioned under section entitled '4. ExecuteTime: show when and how long cells ran', here. In the metadata, is the start_time and end_time for each cell, see here. You can use the start time for the first cell and the end_time for the last cell to give you the total time.
Alternatively, you can use an external call to run the notebook from another notebook and use %%time in that. For example to run the index.ipynb notebook, in a new notebook execute:
%%time
%run index.ipynb
You could use jupytext, papermill, or nbconvert to run the notebook instead of %run if you didn't want output displaying in your timing notebook. (I imagine the time to show that output might contribute and could matter in case of somethings you wish to time?) There is an example of using nbconvert and using the -t flag with the call to scripted version of the notebook to time it here.
Or you could use IPython to call to run the notebook and time this if you didn't want to use an actual separate Jupyter notebook since the %%time magic is inherited from IPython.
Is it possible to evaluate code in a jupyter notebook only within a certain section? Can you place a stopping point in the notebook, for example? Or delimit a section by headers?
I would like to know how to use vi-like key bindings in a Jupyter console -- not just with ipython, but with any kernel.
Previous answers show this is possible for ipython. So, perhaps there is some flag or config file where this can be specified. Jupyter does not appear to have an equivalent to ipython profile and giving the same flagged variables as in ipython does not work.
The Jupyter console documentation almost provides the answer. For the flag, you just need to change the variable name:
jupyter console --kernel=ir --ZMQTerminalInteractiveShell.editing_mode=vi
To set this option globally, you have to add c.ZMQTerminalInteractiveShell.editing_mode='vi' to $HOME/.jupyter/jupyter_console_config.py. It's necessary to prefix the 'c.', similar to what's created when running ipython profile create, which the documentation does not specify.