Skip to content

Commit d19d649

Browse files
committed
Check for juypter notebook environment specifically
1 parent 2260777 commit d19d649

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
@@ -318,14 +318,15 @@ def __repr__(self) -> str:
318318
Returns:
319319
String representation of the DataFrame.
320320
"""
321-
# Check if we're in IPython/Jupyter. If so, we will only use
321+
# Check if we're in a Jupyter notebook. If so, we will only use
322322
# the _repr_html_ output to avoid calling collect() twice.
323323
try:
324324
from IPython import get_ipython
325325

326-
if get_ipython() is not None:
326+
shell = get_ipython().__class__.__name__
327+
if shell == "ZMQInteractiveShell":
327328
return "" # Return empty string to effectively disable
328-
except ImportError:
329+
except (ImportError, NameError):
329330
pass
330331

331332
return self.df.__repr__()

0 commit comments

Comments
 (0)