File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -733,7 +733,11 @@ def just(x):
733
733
except UnicodeError :
734
734
eff_len = max_len
735
735
736
- return justfunc (x [:eff_len ], eff_len )
736
+ if conf_max is not None :
737
+ if (conf_max > 3 ) & (_strlen (x ) > max_len ):
738
+ x = x [:eff_len - 3 ] + '...'
739
+
740
+ return justfunc (x , eff_len )
737
741
738
742
return [just (x ) for x in strings ]
739
743
Original file line number Diff line number Diff line change @@ -61,6 +61,26 @@ def test_repr_tuples(self):
61
61
repr (df )
62
62
df .to_string (col_space = 10 , buf = buf )
63
63
64
+ def test_repr_truncation (self ):
65
+ max_len = 20
66
+ fmt .print_config .max_colwidth = max_len
67
+ df = DataFrame ({'A' : np .random .randn (10 ),
68
+ 'B' : [tm .rands (np .random .randint (max_len - 1 ,
69
+ max_len + 1 )) for i in range (10 )]})
70
+ r = repr (df )
71
+ r = r [r .find ('\n ' ) + 1 :]
72
+ for line , value in zip (r .split ('\n ' ), df ['B' ]):
73
+ if fmt ._strlen (value ) + 1 > max_len :
74
+ self .assert_ ('...' in line )
75
+ else :
76
+ self .assert_ ('...' not in line )
77
+
78
+ fmt .print_config .max_colwidth = None
79
+ self .assert_ ('...' not in repr (df ))
80
+
81
+ fmt .print_config .max_colwidth = max_len + 2
82
+ self .assert_ ('...' not in repr (df ))
83
+
64
84
def test_to_string_repr_unicode (self ):
65
85
buf = StringIO ()
66
86
You can’t perform that action at this time.
0 commit comments