Skip to content

Commit 0b28f0a

Browse files
mroeschkeyehoshuadimarsky
authored andcommitted
DEPR: display.column_space (pandas-dev#47280)
1 parent aba825a commit 0b28f0a

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

doc/source/whatsnew/v1.5.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ Other Deprecations
690690
- Deprecated the ``closed`` argument in :class:`intervaltree` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
691691
- Deprecated the ``closed`` argument in :class:`ArrowInterval` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
692692
- Deprecated allowing ``unit="M"`` or ``unit="Y"`` in :class:`Timestamp` constructor with a non-round float value (:issue:`47267`)
693+
- Deprecated the ``display.column_space`` global configuration option (:issue:`7576`)
693694
-
694695

695696
.. ---------------------------------------------------------------------------

pandas/core/config_init.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,17 @@ def is_terminal() -> bool:
361361
float_format_doc,
362362
validator=is_one_of_factory([None, is_callable]),
363363
)
364-
cf.register_option("column_space", 12, validator=is_int)
364+
365+
def _deprecate_column_space(key):
366+
warnings.warn(
367+
"column_space is deprecated and will be removed "
368+
"in a future version. Use df.to_string(col_space=...) "
369+
"instead.",
370+
FutureWarning,
371+
stacklevel=find_stack_level(),
372+
)
373+
374+
cf.register_option("column_space", 12, validator=is_int, cb=_deprecate_column_space)
365375
cf.register_option(
366376
"max_info_rows",
367377
1690785,

pandas/io/formats/format.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ def format_array(
12941294
fmt_klass = GenericArrayFormatter
12951295

12961296
if space is None:
1297-
space = get_option("display.column_space")
1297+
space = 12
12981298

12991299
if float_format is None:
13001300
float_format = get_option("display.float_format")
@@ -2099,7 +2099,6 @@ def set_eng_float_format(accuracy: int = 3, use_eng_prefix: bool = False) -> Non
20992099
See also EngFormatter.
21002100
"""
21012101
set_option("display.float_format", EngFormatter(accuracy, use_eng_prefix))
2102-
set_option("display.column_space", max(12, accuracy + 9))
21032102

21042103

21052104
def get_level_lengths(

pandas/tests/frame/test_repr_info.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def test_repr_unsortable(self, float_frame):
219219
)
220220
repr(unsortable)
221221

222-
fmt.set_option("display.precision", 3, "display.column_space", 10)
222+
fmt.set_option("display.precision", 3)
223223
repr(float_frame)
224224

225225
fmt.set_option("display.max_rows", 10, "display.max_columns", 2)

pandas/tests/io/formats/test_format.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1442,8 +1442,6 @@ def test_to_string_float_formatting(self):
14421442
fmt.set_option(
14431443
"display.precision",
14441444
5,
1445-
"display.column_space",
1446-
12,
14471445
"display.notebook_repr_html",
14481446
False,
14491447
)
@@ -3402,3 +3400,9 @@ def test_filepath_or_buffer_bad_arg_raises(float_frame, method):
34023400
msg = "buf is not a file name and it has no write method"
34033401
with pytest.raises(TypeError, match=msg):
34043402
getattr(float_frame, method)(buf=object())
3403+
3404+
3405+
def test_col_space_deprecated():
3406+
# GH 7576
3407+
with tm.assert_produces_warning(FutureWarning, match="column_space is"):
3408+
set_option("display.column_space", 11)

0 commit comments

Comments
 (0)