BUG: object
s not converted in DataFrame.convert_dtypes()
on empty DataFrame
#50970
Closed
3 tasks done
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
When calling
DataFrame.convert_dtypes()
on an emptyDataFrame
I noticed that issues with handlingobject
dtypes with both thepandas
andpyarrow
dtype backends.When using the
pandas
dtype backend,object
columns aren't converted tostring[python]
, they instead remainobject
(even thoughconvert_string=True
). When using thepyarrow
backend, we get the following error:cc @mroeschke @phofl for visibility
Expected Behavior
I would expect
convert_dtypes
to behave the same, even if theDataFrame
is empty.Installed Versions
The text was updated successfully, but these errors were encountered: