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: AttributeError: 'tuple' object has no attribute 'rstrip' in format_object_summary #52960

Closed
2 of 3 tasks
qlimaxx opened this issue Apr 27, 2023 · 2 comments · Fixed by #53044
Closed
2 of 3 tasks
Assignees
Labels
Bug MultiIndex Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@qlimaxx
Copy link

qlimaxx commented Apr 27, 2023

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
str(pd.MultiIndex.from_tuples([('c' * 62,)]))

Issue Description

This code will return the following error when the length is 62 or more:

File "pandas/core/indexes/base.py", line 1233, in __repr__
    data = self._format_data()
  File "pandas/core/indexes/base.py", line 1275, in _format_data
    return format_object_summary(
  File "pandas/io/formats/printing.py", line 448, in format_object_summary
    summary, line = _extend_line(summary, line, tail[-1], display_width - 2, space2)
  File "pandas/io/formats/printing.py", line 360, in _extend_line
    if adj.len(line.rstrip()) + adj.len(value.rstrip()) >= display_width:
AttributeError: 'tuple' object has no attribute 'rstrip'

Expected Behavior

The code shouldn't fail

Installed Versions

INSTALLED VERSIONS

commit : 37ea63d
python : 3.10.7.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-147-generic
Version : #164~18.04.1-Ubuntu SMP Tue Apr 4 00:20:20 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.0.1
numpy : 1.24.3
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 63.2.0
pip : 23.0.1
Cython : None
pytest : 7.3.1
hypothesis : 6.72.1
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.9.6
jinja2 : 3.1.2
IPython : None
pandas_datareader: None
bs4 : 4.12.2
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : 2.8.4
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 11.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
snappy : None
sqlalchemy : 2.0.10
tables : None
tabulate : 0.9.0
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

@qlimaxx qlimaxx added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 27, 2023
@qlimaxx qlimaxx changed the title BUG: BUG: AttributeError: 'tuple' object has no attribute 'rstrip' in format_object_summary Apr 27, 2023
@asishm-wk
Copy link

likely caused by #49740

where the

head = [_pprint_seq(x, max_seq_items=max_items) for x in head]
tail = [_pprint_seq(x, max_seq_items=max_items) for x in tail]

block was moved from outside the for loop to the inside

@rhshadrach rhshadrach added Regression Functionality that used to work in a prior pandas version MultiIndex and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Apr 28, 2023
@rhshadrach rhshadrach added this to the 2.0.2 milestone Apr 28, 2023
@Charlie-XIAO
Copy link
Contributor

take

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

Successfully merging a pull request may close this issue.

4 participants