Skip to content

Commit 00a2bb4

Browse files
committed
Check for juypter notebook environment specifically
1 parent 1c80dcd commit 00a2bb4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

python/datafusion/dataframe.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,15 @@ def __repr__(self) -> str:
321321
Returns:
322322
String representation of the DataFrame.
323323
"""
324-
# Check if we're in IPython/Jupyter. If so, we will only use
324+
# Check if we're in a Jupyter notebook. If so, we will only use
325325
# the _repr_html_ output to avoid calling collect() twice.
326326
try:
327327
from IPython import get_ipython
328328

329-
if get_ipython() is not None:
329+
shell = get_ipython().__class__.__name__
330+
if shell == "ZMQInteractiveShell":
330331
return "" # Return empty string to effectively disable
331-
except ImportError:
332+
except (ImportError, NameError):
332333
pass
333334

334335
return self.df.__repr__()

0 commit comments

Comments
 (0)