Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] 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
Comment From: MarcoGorelli
thanks for the report
this is fine on the main
branch, it doesn't raise any warning
if you wanted to dig into where sys.getsizeof
goes and silence this warning where appropriate for the next version in the 1.5.x series, that'd be welcome