+ 6
Chessboard in pandas without gaps
I tried to create a chessboard as pd DataFrame. But I dont find a good solution to get the fields without gaps. Finally I want the middle one but without havint to print the Dataframe row by row https://sololearn.com/compiler-playground/cINjPImL8T42/?ref=app
4 Antworten
+ 4
One more idea: merge all the columns to a single string.
combined = cb.agg(''.join, axis=1)
+ 2
I don't see a benefit of a data frame here.
For nice printing, see my comment on your "corners" code.
+ 2
Also if you stick with the numpy array, you can condense the output with an empty separator:
print("I dont like the gaps")
for row in cb:
print(*row, sep='')
+ 1
I don't think you can do it in the console.
Here is all the formatting options built into pandas. I did not find anything related to column separator.
https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html
Maybe if you print to html, you might be able to apply some custom CSS to remove the padding, margin and border from table cells.