-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG-22984 Fix truncation of DataFrame representations #22987
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
Changes from all commits
eb4a239
8e82c82
448153d
244b295
aa867b0
34b464f
4629504
696e8c7
3faf1a9
126edd9
da08eeb
29239ad
90be7b3
defff22
7aed9e6
f1768c7
547c240
cb51a02
ae938fd
8c29ede
b0c4156
23fae32
1f4bad5
e938ed4
39a2e0a
1b00ec5
0d0b561
6202eb0
58dc180
55e2f3d
5e09698
ed46d6d
c3f6b8b
9a77c2f
feede99
32c22d4
b34cfff
53dad83
510ba4e
6a88f0e
37dd36f
2b626d5
9436e21
1071c28
079f632
013315a
662759a
6efd331
1da1d63
2acb22c
898c2a2
fa8e130
278124e
863e628
5244647
c611272
4d4b583
8c280ca
574a03a
73cc01b
43b135f
31eee47
737cb7d
13f41ae
6d4178a
66a95bc
3bb2f75
af33308
cf5e385
7c0b5d0
db58d3d
b62634f
2c193a0
6244f35
03d632c
01ffb03
56b8024
84ef701
e4104e9
eefb76e
af8ca26
d8d6222
cffdb0e
b265308
f2eac44
fef6d7a
c80ff12
ff8130b
9977a08
1d861de
c355f26
a4c1490
468df9c
6401a4f
92b015d
519de0b
d4be020
d8826bf
3b87703
999ef43
7fc3732
bb9f4eb
76c078c
fdda5d7
d3e43f8
c7dc40c
f7556a4
951041e
d5d6d91
4242077
c1640c6
8e4bf4c
b3a3ac7
7dab45f
991547e
c8ac3bf
f9563ea
2688cbe
d0adfb0
f452c40
36f0608
8459936
0f7aa4b
82fa50c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -305,14 +305,10 @@ def test_repr_non_interactive(self): | |
assert not has_truncated_repr(df) | ||
assert not has_expanded_repr(df) | ||
|
||
def test_repr_truncates_terminal_size(self): | ||
def test_repr_truncates_terminal_size(self, mock): | ||
# https://github.com/pandas-dev/pandas/issues/21180 | ||
# TODO: use mock fixutre. | ||
# This is being backported, so doing it directly here. | ||
try: | ||
from unittest import mock | ||
except ImportError: | ||
mock = pytest.importorskip("mock") | ||
|
||
terminal_size = (118, 96) | ||
p1 = mock.patch('pandas.io.formats.console.get_terminal_size', | ||
|
@@ -343,6 +339,17 @@ def test_repr_truncates_terminal_size(self): | |
|
||
assert df2.columns[0] in result.split('\n')[0] | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: we have a pytest fixture formock now, that does the try / except / skip done above. I think it'd be cleanest to split this into a new test here, and accept the def test_repr_truncates_terminal_size_full(self, mock):
... Any if you're feeling adventurous, you could change the try / except / skip mock import above to use the fixture as well. Not a big deal though. |
||
def test_repr_truncates_terminal_size_full(self, mock): | ||
# GH 22984 ensure entire window is filled | ||
terminal_size = (80, 24) | ||
df = pd.DataFrame(np.random.rand(1, 7)) | ||
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) | ||
with p1, p2: | ||
assert "..." not in str(df) | ||
|
||
def test_repr_max_columns_max_rows(self): | ||
term_width, term_height = get_terminal_size() | ||
if term_width < 10 or term_height < 10: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a number of tests for this, suprised this didn't break anything, can you make a test if we have no coverage for this case now? (e.g. you use option_context to set the width, then check the output string)