Description
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
df = pd.DataFrame(
index=['a', 'b'],
)
sys.getsizeof(df)
Issue Description
The line sys.getsizeof(df)
above correctly evaluates to the size of the DataFrame, but it also gives warning:
/tmp/ipykernel_6588/3506259561.py:7: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
sys.getsizeof(df)
I came across this bug while using the package anndata
, which facilitates storing metadata for the rows and columns of numpy
arrays. This metadata is stored in pandas
DataFrames, and it's common to have a metadata DataFrame with only an index and no columns. Hence computing sys.getsizeof()
of an anndata.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