You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been trying to use some memory profiling tools, to profile my code. With two different memory profilers, both of which use sys.getsizeof(obj), pandas has been the cause of a TypeError returned. I am posting below an example using the memory-tools package.
Code Sample
I have tested the following code independently in a Jupyter notebook environment, separate from my other code. It should (hopefully) be a minimal example that can be reproduced. I am happy to provide more information on my environment if needed.
from memorytools import summarize_objects
import pandas as pd
summarize_objects()
Error Returned
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-c46dbac041c7> in <module>()
----> 1 summarize_objects()
/Users/ericmjl/Documents/github/memory-tools/src/memorytools/__init__.py in summarize_objects(objs, echo, limit)
90 objs = gc.get_objects()
91
---> 92 objs_dict = _summarize_objects(objs)
93 size_summary = ['{0:>10s} {1:>5s} {2}'.format('Size', 'Count', 'Type')]
94 count_summary = ['{0:>5s} {1:>10s} {2}'.format('Count', 'Size', 'Type')]
/Users/ericmjl/Documents/github/memory-tools/src/memorytools/__init__.py in _summarize_objects(objs)
133 for obj in objs:
134 _incr(objs_dict, type(obj), 'count')
--> 135 _incr(objs_dict, type(obj), 'size', sys.getsizeof(obj))
136
137 return objs_dict
/Users/ericmjl/anaconda/lib/python3.5/site-packages/pandas/core/base.py in __sizeof__(self)
128 # no memory_usage attribute, so fall back to
129 # object's 'sizeof'
--> 130 return super(self, PandasObject).__sizeof__()
131
132
TypeError: must be type, not FrozenList
Please pardon my ignorance on this matter, but would someone be kind enough to educate me on why this error is thrown, and how I might be able to fix this? If there's a maintainer who could provide some guidance, I am happy to dig into the codebase and submit a PR if that will fix the error.
I have been trying to use some memory profiling tools, to profile my code. With two different memory profilers, both of which use
sys.getsizeof(obj)
,pandas
has been the cause of aTypeError
returned. I am posting below an example using thememory-tools
package.Code Sample
I have tested the following code independently in a Jupyter notebook environment, separate from my other code. It should (hopefully) be a minimal example that can be reproduced. I am happy to provide more information on my environment if needed.
Error Returned
Please pardon my ignorance on this matter, but would someone be kind enough to educate me on why this error is thrown, and how I might be able to fix this? If there's a maintainer who could provide some guidance, I am happy to dig into the codebase and submit a PR if that will fix the error.
output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: