Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: maybe_convert_objects fails for byte series #49650

Closed
3 tasks done
lbittarello opened this issue Nov 11, 2022 · 7 comments · Fixed by #50067
Closed
3 tasks done

BUG: maybe_convert_objects fails for byte series #49650

lbittarello opened this issue Nov 11, 2022 · 7 comments · Fixed by #50067
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@lbittarello
Copy link

lbittarello commented Nov 11, 2022

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

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.")
@lbittarello lbittarello added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 11, 2022
@phofl
Copy link
Member

phofl commented Nov 14, 2022

Hi, thanks for your report. This was caused by #49590

cc @jbrockmendel Was this intended?

@phofl phofl added this to the 2.0 milestone Nov 14, 2022
@phofl phofl added Dtype Conversions Unexpected or buggy dtype conversions Regression Functionality that used to work in a prior pandas version and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 14, 2022
@jbrockmendel
Copy link
Member

no that was not intended

@jbrockmendel
Copy link
Member

though i think something may be fishy with dtype="bytes", id expect that to cast to object dtype

@phofl
Copy link
Member

phofl commented Dec 5, 2022

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?

@jbrockmendel
Copy link
Member

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

@phofl
Copy link
Member

phofl commented Dec 5, 2022

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

@jbrockmendel
Copy link
Member

no. if its self.dtype!=object then there is no need to do inference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants