We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c99f867 commit 722d65dCopy full SHA for 722d65d
src/inspectorscripts.ts
@@ -77,9 +77,12 @@ def _jupyterlab_variableinspector_getsizeof(x):
77
elif __torch and isinstance(x, __torch.Tensor):
78
return x.element_size() * x.nelement()
79
elif __pd and type(x).__name__ == 'DataFrame':
80
- # DO NOT CALL df.memory_usage() as this can be very costly
81
- # to the point of crashing the kernel
82
- return "?"
+ # DO NOT CALL df.memory_usage() for big dataframes as this can be very costly
+ # to the point of making the kernel unresponsive or crashing it
+ if len(x.columns) < 10_000:
83
+ return x.memory_usage().sum()
84
+ else:
85
+ return "?"
86
else:
87
return sys.getsizeof(x)
88
0 commit comments