BUG: Computing sys.getsizeof
a DataFrame with no columns results in an irrelevant FutureWarning
#50066
Closed
3 tasks done
Labels
Bug
DataFrame
DataFrame data structure
Regression
Functionality that used to work in a prior pandas version
Milestone
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
The line
sys.getsizeof(df)
above correctly evaluates to the size of the DataFrame, but it also gives warning:I came across this bug while using the package
anndata
, which facilitates storing metadata for the rows and columns ofnumpy
arrays. This metadata is stored inpandas
DataFrames, and it's common to have a metadata DataFrame with only an index and no columns. Hence computingsys.getsizeof()
of ananndata.AnnData()
object with no metadata for either its rows or columns produces this warning.Expected Behavior
Calling sys.getsizeof() shouldn't display this irrelevant warning.
Installed Versions
INSTALLED VERSIONS
commit : 8dab54d
python : 3.9.13.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.219-126.411.amzn2.x86_64
Version : #1 SMP Wed Nov 2 17:44:17 UTC 2022
machine : x86_64
processor :
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.5.2
numpy : 1.23.0
pytz : 2022.1
dateutil : 2.8.2
setuptools : 59.5.0
pip : 22.1.2
Cython : 0.29.30
pytest : 7.1.2
hypothesis : None
sphinx : 5.0.2
blosc : None
feather : None
xlsxwriter : 3.0.3
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.4.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli :
fastparquet : 2022.11.0
fsspec : 2022.5.0
gcsfs : None
matplotlib : 3.5.2
numba : 0.53.1
numexpr : 2.7.3
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 10.0.1
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.1
snappy : None
sqlalchemy : 1.4.37
tables : 3.7.0
tabulate : 0.8.10
xarray : None
xlrd : 1.2.0
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: