Skip to content

BUG: memory_usage(deep=True) of dtype='string' is wrong #33963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
mizuy opened this issue May 4, 2020 · 1 comment · Fixed by #33985
Closed
3 tasks done

BUG: memory_usage(deep=True) of dtype='string' is wrong #33963

mizuy opened this issue May 4, 2020 · 1 comment · Fixed by #33985
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays. Strings String extension data type and string data

Comments

@mizuy
Copy link

mizuy commented May 4, 2020

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample, a copy-pastable example

In [4]: s = pd.Series(['a','b','c'],dtype='object')
   ...: print(s.memory_usage())
   ...: print(s.memory_usage(deep=True))
152
326

In [5]: s = pd.Series(['a','b','c'],dtype='string')
   ...: print(s.memory_usage())
   ...: print(s.memory_usage(deep=True))
152
152

Problem description

memory_usage(deep=True) for new 'string' dtype is not 'deep' size.

Expected Output

In [3]: s = pd.Series(['a','b','c'],dtype='string')
...: print(s.memory_usage())
...: print(s.memory_usage(deep=True))
152
326

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit : None python : 3.7.4.final.0 python-bits : 64 OS : Darwin OS-release : 18.7.0 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : None LOCALE : en_US.UTF-8

pandas : 1.0.3
numpy : 1.17.3
pytz : 2019.3
dateutil : 2.8.0
pip : 20.1
setuptools : 40.8.0
Cython : 0.29.16
pytest : 5.2.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.2.2
lxml.etree : 4.4.2
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.8.0
pandas_datareader: None
bs4 : 4.9.0
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.4.2
matplotlib : 3.1.1
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.0
pandas_gbq : None
pyarrow : 0.15.0
pytables : None
pytest : 5.2.1
pyxlsb : None
s3fs : 0.2.2
scipy : 1.3.1
sqlalchemy : None
tables : None
tabulate : 0.8.5
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : 1.2.2
numba : None

@mizuy mizuy added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 4, 2020
@jorisvandenbossche jorisvandenbossche added ExtensionArray Extending pandas with custom dtypes or arrays. Strings String extension data type and string data and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 4, 2020
@jorisvandenbossche
Copy link
Member

@mizuy thanks for the report!
That's indeed not correct.

We should probably add a memory_usage method to StringArray, so that can have a deep=True keyword.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays. Strings String extension data type and string data
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants