Issue
I've been trying to make a minesweeper board on Spyder, but I've encountered a problem with my pandas data frame. The values in the grid are colored (using colorama).
the program:
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("----------------------------------")
Using visual studio code : the dataframe on VSC
Using spyder : the same dataframe on spyder
I've already tried to use :
pandas.set_option('display.max_rows', None, 'display.max_columns', None)
but didn't work
How can I get the same result that I get on VSC, on Spyder ?
Let me know if you want more information.
Thanks, Ikseno
Solution
Try these settings right after your pandas.DataFrame call:
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)
I get this in Spyder with those settings:
Answered By - Cary Cox
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.