From 2cec070ebf4f1958d4ffef98d7649eda21ac09a3 Mon Sep 17 00:00:00 2001 From: Keewis Date: Wed, 26 Oct 2022 15:07:06 +0200 Subject: [PATCH] implement option 3: light box components in front of the coord names --- xarray/core/formatting.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/xarray/core/formatting.py b/xarray/core/formatting.py index 6875afa29b3..57bab84bb4d 100644 --- a/xarray/core/formatting.py +++ b/xarray/core/formatting.py @@ -425,8 +425,18 @@ def summarize_index( if max_width is None: max_width = OPTIONS["display_width"] + def prefix(index, length): + if index == 0 and length == 1: + return " " + elif index == 0: + return "┌" + elif index >= length - 1: + return "└" + else: + return "│" + preformatted = [ - pretty_print(f" {'-' if index == 0 else ' '} {name} ", col_width) + pretty_print(f" {prefix(index, len(names))} {name} ", col_width) for index, name in enumerate(names) ]