Skip to content

Commit 72bc9ad

Browse files
committed
Check for juypter notebook environment specifically
1 parent 907aef5 commit 72bc9ad

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
@@ -149,14 +149,15 @@ def __repr__(self) -> str:
149149
Returns:
150150
String representation of the DataFrame.
151151
"""
152-
# Check if we're in IPython/Jupyter. If so, we will only use
152+
# Check if we're in a Jupyter notebook. If so, we will only use
153153
# the _repr_html_ output to avoid calling collect() twice.
154154
try:
155155
from IPython import get_ipython
156156

157-
if get_ipython() is not None:
157+
shell = get_ipython().__class__.__name__
158+
if shell == "ZMQInteractiveShell":
158159
return "" # Return empty string to effectively disable
159-
except ImportError:
160+
except (ImportError, NameError):
160161
pass
161162

162163
return self.df.__repr__()

0 commit comments

Comments
 (0)