Skip to content

Commit 4430621

Browse files
committed
add numpy shape as size
1 parent 2274d7b commit 4430621

File tree

1 file changed

+4
-2
lines changed
  • src/jupyter_contrib_nbextensions/nbextensions/varInspector

1 file changed

+4
-2
lines changed

src/jupyter_contrib_nbextensions/nbextensions/varInspector/var_list.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from IPython import get_ipython
55
from IPython.core.magics.namespace import NamespaceMagics
6-
6+
import numpy as np
77
_nms = NamespaceMagics()
88
_Jupyter = get_ipython()
99
_nms.shell = _Jupyter.kernel.shell
@@ -12,7 +12,9 @@
1212
def _getsizeof(x):
1313
# return the size of variable x. Amended version of sys.getsizeof
1414
# which also supports ndarray, Series and DataFrame
15-
if type(x).__name__ in ['ndarray', 'Series']:
15+
if type(x) is np.ndarray:
16+
return x.shape
17+
elif type(x).__name__ in ['ndarray', 'Series']:
1618
return x.nbytes
1719
elif type(x).__name__ == 'DataFrame':
1820
return x.memory_usage().sum()

0 commit comments

Comments
 (0)