-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
MultiIndex to_string
edge case Error after 0.23.0 upgrade
#21180
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
Comments
to_string
edge case Error after 0.23.0 upgradeto_string
edge case Error after 0.23.0 upgrade
This doesn't raise for me (py36, and pandas master). What is |
@TomAugspurger Here my system pandas 0.23.0 output:
0.22.0 output:
If I do the following it works in 0.23.0!
Did the default setting change in 0.23.0? |
Reading the docs show how 0.22:
has been updated in 0.23 to:
However, when switching back to 0.22.0 and manually changing the 🤔 So it still doesn't explain why there would be an error raised when |
cc @cbrnr if you have any ideas. |
I get an |
You need to recompile the extension modules. Commands for your platform should be in the contributing docs.
…________________________________
From: Clemens Brunner <[email protected]>
Sent: Monday, May 28, 2018 1:48:25 AM
To: pandas-dev/pandas
Cc: Tom Augspurger; Mention
Subject: Re: [pandas-dev/pandas] MultiIndex `to_string` edge case Error after 0.23.0 upgrade (#21180)
I get an AttributeError: module 'pandas._libs.tslibs.timezones' has no attribute 'tz_standardize' when I test this with the latest master branch revision. Any ideas how to fix this? Using 0.23, I can reproduce the issue.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#21180 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABQHIikYuSBQuVOuVYnZ4mSdLRkxq_pCks5t2525gaJpZM4UKJe1>.
|
Thanks, I forgot about that. Thankfully, it's not the add one business (I get the same error when I revert this change). This will take a bit of work, since everything works in PyCharm but not in IPython (so debugging will be much slower for me since I'm not used to pdb at all)... |
Apparently, setting |
Hi @cbrnr
Probably you ment to say |
No, I get the same error with pandas 0.22 if I first set |
I do not get the exception on pandas 0.22.0 with import pandas as pd
pd.options.display.max_columns = 0
import numpy as np
index = pd.date_range('1970', '2018', freq='A')
data = np.random.randn(len(index))
columns1 = [
['This is a long title with > 37 chars.'],
['cat'],
]
columns2 = [
['This is a loooooonger title with > 43 chars.'],
['dog'],
]
df1 = pd.DataFrame(data=data, index=index, columns=columns1)
df2 = pd.DataFrame(data=data, index=index, columns=columns2)
df = pd.concat([df1, df2], axis=1)
df.head() |
Though it occurs to me that this probably depends on the width of the terminal. |
not a regression, but still should fix. |
@TomAugspurger I just tried again, I do get the error with 0.22. How are you running this code? If you are not in interactive mode (e.g. IPython), you need to change the last line to |
@jreback could you please make a note when you're moving the milestone? This should be fixed for 0.23.1. |
i made a note pls don’t mark milestones unless ready to go |
@jreback This is a regression in user experience. It may be an existing bug, but code that was working before, is failing now, because we changed the default. So we should still fix that existing bug for 0.23.1. I cannot reproduce the error with the example in this issue, but I do see it with the example from #21327 |
@jorisvandenbossche sure regressions happen, and we should fix them all. but unless this is fixed today, it will go in the next release. |
We can also change the default of max_columns back to 20 for now if we don't find the effort to fix the bugs |
Here's a failing unit test diff --git a/pandas/tests/io/formats/test_format.py b/pandas/tests/io/formats/test_format.py
index f221df93d..52f83f093 100644
--- a/pandas/tests/io/formats/test_format.py
+++ b/pandas/tests/io/formats/test_format.py
@@ -305,6 +305,36 @@ class TestDataFrameFormatting(object):
assert not has_truncated_repr(df)
assert not has_expanded_repr(df)
+ def test_repr_multiindex(self):
+ # https://github.com/pandas-dev/pandas/issues/21180
+ from unittest import mock
+
+ def f():
+ return os.terminal_size((118, 96))
+
+ terminal_size = os.terminal_size((118, 96))
+
+ p1 = mock.patch('pandas.io.formats.console.get_terminal_size',
+ return_value=terminal_size)
+ p2 = mock.patch('pandas.io.formats.format.get_terminal_size',
+ return_value=terminal_size)
+ index = pd.date_range('1970', '2018', freq='A')
+ data = np.random.randn(len(index))
+ columns1 = [
+ ['This is a long title with > 37 chars.'],
+ ['cat'],
+ ]
+ columns2 = [
+ ['This is a loooooonger title with > 43 chars.'],
+ ['dog'],
+ ]
+ df1 = pd.DataFrame(data=data, index=index, columns=columns1)
+ df2 = pd.DataFrame(data=data, index=index, columns=columns2)
+ df = pd.concat([df1, df2], axis=1)
+
+ with p1, p2:
+ repr(df.head())
+
def test_repr_max_columns_max_rows(self):
term_width, term_height = get_terminal_size()
if term_width < 10 or term_height < 10: |
If we don't have a fix for this, I would consider reverting the Errors in the repr are really annoying, as you cannot even inspect the data properly to see what might be the reason something is not working. |
I'm going to try to fix it now. |
What's the expected behavior here? I can easily match the behavior of the non-MI case, In [3]: s = pd.DataFrame({"A" * 41: [1, 2], 'B' * 41: [1, 2]})
In [4]: with p1, p2:
...: print(repr(s))
...:
...
0 ...
1 ...
[2 rows x 2 columns] but that's not too useful... |
That's a good question. For the truncated repr, we always need two columns right? (first and last) |
Overflowing the line is what is happening in my console if I make it smaller (instead of the error), that might be an option in general (it does not make the repr very readable for this case, but at least would not lead to an error) |
Code example
Output (using pandas 0.23.0)
Problem description
After upgrading Pandas 0.22.0 to 0.23.0 I have experienced the above error. I have noticed that it is the length of the column values,
This is a long title with > 37 chars.
andThis is a loooooonger title with > 43 chars.
, that makes the difference. If I tweak the combined length of these to be <= 80 characters, there is no error, and output is as expected.Expected Output (using pandas 0.22.0)
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-124-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_ZA.UTF-8
LOCALE: en_ZA.UTF-8
pandas: 0.23.0
pytest: None
pip: 10.0.1
setuptools: 32.3.1
Cython: None
numpy: 1.14.0
scipy: None
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2018.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: 2.5.3
xlrd: None
xlwt: None
xlsxwriter: 1.0.4
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: 2.7.4 (dt dec pq3 ext lo64)
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: