【发布时间】:2019-11-16 09:38:10
【问题描述】:
如何使用命令 df.head() 将 pandas 数据框中的标题文本居中?现在对齐在右边,如何改变它? 我在 jupyterlab 1.0 中使用 Python 3.6
代码:
pd.set_option('colheader_justify', 'center')
不适用于 df.head() 命令。替代品?
【问题讨论】:
标签: python pandas jupyter-lab
如何使用命令 df.head() 将 pandas 数据框中的标题文本居中?现在对齐在右边,如何改变它? 我在 jupyterlab 1.0 中使用 Python 3.6
代码:
pd.set_option('colheader_justify', 'center')
不适用于 df.head() 命令。替代品?
【问题讨论】:
标签: python pandas jupyter-lab
用途:
pd.set_option('colheader_justify', 'center')
这是一个例子:
df = pd.DataFrame(np.array([np.random.randn(6),
np.random.randint(1, 9, 6) * .1,
np.zeros(6)]).T,
columns=['A', 'B', 'C'], dtype='float')
pd.set_option('colheader_justify', 'center')
print(df)
A B C
0 -0.600705 0.5 0.0
1 -0.195192 0.6 0.0
2 -1.227175 0.8 0.0
3 0.625125 0.7 0.0
4 -0.455949 0.3 0.0
5 -0.809112 0.7 0.0
【讨论】: