我尝试使用set_table_styles设置表格宽度,但它不起作用。我试图在文档中查找有关此的信息,但那里没有示例。https://pandas.pydata.org/docs/user_guide/style.html
我调查了这个问题,但它也没有帮助。Set width to 100% (fill container) with pandas set_table_styles
我的部分代码:
turnover = pd.pivot_table(data_for_turnover, columns=['Date'], values=['Turnover', 'Sales', 'Stocks'], aggfunc='sum')
table_style = {'selector': 'table','props': [('width', '100%')]}
turnover = turnover.style.format('{:.0f}')
turnover.set_table_styles([table_style]).to_html()
字符串
接下来我使用Django显示,但宽度(我也尝试改变边框,边距)不改变.如果我尝试改变th或td样式,他们被应用.请帮助我找到,如果不是一个解决方案,然后一个原因.
1条答案
按热度按时间uttx8gqw1#
我认为如果你需要设置一个固定的
width
的html表,你应该使用pixels而不是%
s。字符串
输出(* 单位:字节 *):
的数据
Used input(to mock your
pivot_table
):型