My search turned up this thread while trying to find an alternative to your 
second suggestion of using a  boolean toggle. This works fine for the most 
part, and I use it often. However, I cannot display the contents of a 
pandas data frame the way I'd like to from within the "if block". To follow 
your code,


include pandas as pd
data = pd.read_excel(xlsPath + xlsFile)
TESTING = True

# this shows all data with no formatting,
print(data)

# this formats the data into a table and displays it
# (how I'd like it to look),
data

# but when I try this, I get no output whatsoever.
if TESTING:
    data


Here's my version information. Any suggestions would be greatly 
appreciated. I'm wondering if this may be a bug in the pandas library?

Server Information:

You are using Jupyter notebook.

The version of the notebook server is: *5.7.4*
The server is running on this version of Python:

Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 
bit (AMD64)]

Current Kernel Information:

Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 11:27:44) [MSC v.1900 64 
bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help.



On Wednesday, February 15, 2017 at 3:44:07 PM UTC-5, Paul Hobson wrote:
>
> One option would be raise an exception in a new cell above your tester 
> cell.
>
> Another option would be to a variable defined in the notebooks first cell (
> TESTING=False). You can then wrap your tests in an if testing: block, 
> setting testing to True if you actually want them to run.
>
> On Wed, Feb 15, 2017 at 12:11 PM, John Marino <[email protected] 
> <javascript:>> wrote:
>
>> As I develop a notebook, I like to store tester code down at the bottom.  
>> But this means I can't Run All or Run All Below without the tester code 
>> running.  (Yes, I can scroll down and Run All Above.)  Is there something I 
>> can enter into a cell that would keep the notebook from continuing to run 
>> cells?  I don't want to halt the kernel or interrupt what is running (i.e. 
>> I don't want an exception thrown).  I'm thinking a magic, e.g. %stop, would 
>> do the trick.  (I looked at the existing magics, but didn't find anything 
>> like this.)
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Project Jupyter" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jupyter/75cbcc60-69d6-4bc3-bccc-70dfce541c40%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jupyter/75cbcc60-69d6-4bc3-bccc-70dfce541c40%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/817c8af8-e9b6-48d5-8a86-e15b068e6056%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to