@@ -1523,7 +1523,7 @@ def test_to_string_no_index(self):
1523
1523
1524
1524
def test_to_string_float_formatting (self ):
1525
1525
self .reset_display_options ()
1526
- fmt .set_option ('display.precision' , 6 , 'display.column_space' ,
1526
+ fmt .set_option ('display.precision' , 5 , 'display.column_space' ,
1527
1527
12 , 'display.notebook_repr_html' , False )
1528
1528
1529
1529
df = DataFrame ({'x' : [0 , 0.25 , 3456.000 , 12e+45 , 1.64e+6 ,
@@ -1554,7 +1554,7 @@ def test_to_string_float_formatting(self):
1554
1554
self .assertEqual (df_s , expected )
1555
1555
1556
1556
self .reset_display_options ()
1557
- self .assertEqual (get_option ("display.precision" ), 7 )
1557
+ self .assertEqual (get_option ("display.precision" ), 6 )
1558
1558
1559
1559
df = DataFrame ({'x' : [1e9 , 0.2512 ]})
1560
1560
df_s = df .to_string ()
@@ -3055,7 +3055,7 @@ def test_output_significant_digits(self):
3055
3055
# Issue #9764
3056
3056
3057
3057
# In case default display precision changes:
3058
- with pd .option_context ('display.precision' , 7 ):
3058
+ with pd .option_context ('display.precision' , 6 ):
3059
3059
# DataFrame example from issue #9764
3060
3060
d = pd .DataFrame ({'col1' :[9.999e-8 , 1e-7 , 1.0001e-7 , 2e-7 , 4.999e-7 , 5e-7 , 5.0001e-7 , 6e-7 , 9.999e-7 , 1e-6 , 1.0001e-6 , 2e-6 , 4.999e-6 , 5e-6 , 5.0001e-6 , 6e-6 ]})
3061
3061
@@ -3070,6 +3070,17 @@ def test_output_significant_digits(self):
3070
3070
for (start , stop ), v in expected_output .items ():
3071
3071
self .assertEqual (str (d [start :stop ]), v )
3072
3072
3073
+ def test_too_long (self ):
3074
+ # GH 10451
3075
+ with pd .option_context ('display.precision' , 4 ):
3076
+ # need both a number > 1e8 and something that normally formats to having length > display.precision + 6
3077
+ df = pd .DataFrame (dict (x = [12345.6789 ]))
3078
+ self .assertEqual (str (df ), ' x\n 0 12345.6789' )
3079
+ df = pd .DataFrame (dict (x = [2e8 ]))
3080
+ self .assertEqual (str (df ), ' x\n 0 200000000' )
3081
+ df = pd .DataFrame (dict (x = [12345.6789 , 2e8 ]))
3082
+ self .assertEqual (str (df ), ' x\n 0 1.2346e+04\n 1 2.0000e+08' )
3083
+
3073
3084
3074
3085
class TestRepr_timedelta64 (tm .TestCase ):
3075
3086
0 commit comments