我有这个 numpy 数组
import numpy as np
from tabulate import tabulate
data = np.array([[1,2], [3,4]])
data2 = tabulate(data, tablefmt='fancy_grid')
print(data2)
╒═══╤═══╕
│ 1 │ 2 │
├───┼───┤
│ 3 │ 4 │
╘═══╧═══╛
我对更清晰的表格显示感兴趣,而忽略了我不感兴趣的值。如何打印特定值的空白单元格?例如,数组中所有 2 个值的空白,如下所示:
╒═══╤═══╕
│ 1 │ │
├───┼───┤
│ 3 │ 4 │
╘═══╧═══╛