Python - Spyder 没有显示整个 Pandas DataFrame(而 VSC 显示正确)

Python - Spyder isn't displaying the entire Pandas DataFrame (whereas VSC is displaying it correctly)

我一直在尝试在 Spyder 上制作扫雷板,但我的 pandas 数据框遇到了问题。网格中的值是彩色的(使用 colorama)。

程序:

import numpy 
import pandas
from colorama import Fore

def color(col, mot):
    if col=="red":
        mot =  Fore.RED + str(mot) + Fore.RESET
    if col=="white":
        mot =  Fore.WHITE + str(mot) + Fore.RESET
    if col =="blue":
        mot = Fore.BLUE + str(mot) + Fore.RESET
    if col == "green":
        mot = Fore.GREEN + str(mot) + Fore.RESET
    return mot

grid = [['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m'], ['\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m', '\x1b[37m.\x1b[39m']]

x = numpy.array(grid)
row_labels = ['L1', 'L2', 'L3', 'L4','L5','L6','L7','L8','L9','L10']
column_labels = [color("white",'C1'), color("white",'C2'), color("white",'C3'), color("white",'C4'),color("white",'C5'),color("white",'C6'),color("white",'C7'),color("white",'C8'),color("white",'C9'),color("white",'C10')]

df = pandas.DataFrame(x,columns=column_labels, index=row_labels)

print("-------------" + color("red", "Demineur") + "-------------")
print()
print(df)
print()
print("----------------------------------")

使用 visual studio 代码: the dataframe on VSC

使用 spyder: the same dataframe on spyder

我已经尝试使用 :

pandas.set_option('display.max_rows', None, 'display.max_columns', None)

但没用

如何获得与在 VSC 和 Spyder 上相同的结果?

如果您需要更多信息,请告诉我。

谢谢,Ikseno

在 pandas.DataFrame 通话后立即尝试这些设置:

df = pandas.DataFrame(x,columns=column_labels, index=row_labels)
pandas.set_option('display.max_rows', 500)
pandas.set_option('display.max_columns', 500)
pandas.set_option('display.width', 1000)

我在 Spyder 中使用这些设置得到了这个: