I'm trying to modify this answer and get more spacing between columns.
import pandas as pd
df = pd.DataFrame({'A': [1,10],
'B': ['B','BBBBBB'],
'C': [0,1000],
'D': ['D','DDDDDD']})
#https://stackoverflow.com/a/5667535/3014199
spacing = dict(selector="table",props=[('border-collapse', 'separate'),
('border-spacing', '100px 500px')])
# Style
result=df.style.set_properties(subset=df.columns[[0,2]], **{'text-align':'right'})\
.set_properties(subset=df.columns[[1,3]], **{'text-align':'left'})\
.set_table_styles([spacing])
print(result.render(),file=open('test.html','w'))
But despite ridiculous values, the columns don't seem any further apart.
adding e.g. 'padding-right':'10px',
in set_properties
seems to work, but I want to do things right.
(Also, how can I suppress the index, it was index=False
for .to_html
but where to put it here?)