我有以下Python脚本生成HTML表。现在我想更改表的某些样式,但是我在更改标题的字体大小方面遇到了问题。
epoch = tf.Variable(0, trainable=False) # 0 is initial value
# increment by 1 when the next op is run
epoch_incr_op = tf.assign_add(epoch, 1, name='incr_epoch')
# Define any operations that depend on 'epoch'
# Note we need to cast the integer 'epoch' to float to use in tf.pow
grad_W = grad_W + tf.random_normal(grad_W.shape, 0.0,
1.0/tf.pow(1+tf.cast(epoch, tf.float32), 0.55))
# Training loop
while running_epoch:
_, _, cost_ = sess.run([new_W, new_b ,cost],
feed_dict = {X_: X_train_tr, Y: labels_, learning_rate: learning_r})
# At end of epoch, increment epoch counter
sess.run(epoch_incr_op)
如何更改标题的样式?
import pandas as pd
df = pd.DataFrame({'col1': [1, 2, 3, 4]})
html = (df.style
.set_table_styles({'selector': 'th', 'props': [('font-size', '5pt')]})
.set_properties(**{'font-size': '10pt'}).render())
f = open('test.html', 'wb')
f.write(html)
答案 0 :(得分:2)
我发现我需要将参数作为列表传递给Styler.set_table_styles()
。它现在使用以下代码。
html = (df.style
.set_table_styles([{'selector': 'th', 'props': [('font-size', '5pt')]}])
.set_properties(**{'font-size': '10pt'}).render())