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
import pandas as pd
pd.Series([b"a"], dtype="bytes").infer_objects()
Issue Description
The nightly version of maybe_convert_objects
has been throwing an error for byte series for the past couple of days. Not sure if the recent refactoring (#49588) has something to do with it.
Expected Behavior
The code runs through and returns the unmodified series with the latest release.
Installed Versions
INSTALLED VERSIONS
------------------
commit : 6ba52161147f2543d6cd4194958b0071fec6d1dc
python : 3.11.0.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.22621
machine : AMD64
processor : AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United Kingdom.1252
pandas : 2.0.0.dev0+642.g6ba5216114
numpy : 1.23.4
pytz : 2022.6
dateutil : 2.8.2
setuptools : 65.5.1
pip : 22.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.6.0
pandas_datareader: None
bs4 : None
bottleneck : None
brotli :
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : None
qtpy : None
pyqt5 : None
c:\Programs\Python\envs\pandas_nightly\Lib\site-packages\_distutils_hack\__init__.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
Comment From: phofl
Hi, thanks for your report. This was caused by #49590
cc @jbrockmendel Was this intended?
Comment From: jbrockmendel
no that was not intended
Comment From: jbrockmendel
though i think something may be fishy with dtype="bytes", id expect that to cast to object dtype
Comment From: phofl
This is part of the wider problem that we sometimes end up with numpy str or bytes dtype and cast in some other cases.
Would you be ok with reverting the try/except removal till we can come up with a general solution?
Comment From: jbrockmendel
Would you be ok with reverting the try/except removal till we can come up with a general solution?
I'd suggest adding a check in ObjectBlock.convert for self.dtype == object
Comment From: phofl
Just that I understand you: You would cast self.values to object if this check fails?
This would not get rid of the problem that we sometimes end up with bytes dtype in the Series constructor
Comment From: jbrockmendel
no. if its self.dtype!=object then there is no need to do inference