I have often this problem, when I'm slicing or subsetting data that I want to view/print [df.head()]
the data and look into into it before writing next line of my code. For this case, every time, I have to run the whole block(cell) in ipython, even if I have some logic written I had to comment that block and execute my print line alone.
Is there a feature where you can select a single line and execute it.
Run > Run Selected Text or Current Line in Console , optionally with a keyboard shortcut.
To run a piece of code, click on the cell to select it, then press SHIFT+ENTER or press the play button in the toolbar above. Additionally, the Cell dropdown menu has several options to run cells, including running one cell at a time or to run all cells at once.
Capturing Output With %%capture IPython has a cell magic, %%capture , which captures the stdout/stderr of a cell. With this magic you can discard these streams or store them in a variable. By default, %%capture discards these streams. This is a simple way to suppress unwanted output.
I often start a qtconsole attached to the kernel. You can do that as follows:
%qtconsole
and execute that cell.Once you have a qtconsole that is attached to the notebook kernel. You can print the value of variables there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With