python - 用pandas展示数据输出时列名不能对齐?
阿神
阿神 2017-04-18 10:07:44
0
1
892

用pandas的sort_values对数据进行排序后输出,发现列名一直没法对齐,这是为什么?

阿神
阿神

闭关修行中......

reply all(1)
伊谢尔伦

The reason is because the print operation is for service under the console line, and this display can basically only meet basic needs.

Use jupyter的话,可以直接去掉print, the table will be parsed into an HTML table, and this problem will disappear.

However, a code cell can only output one result by default. If it is output at the same time

df1
df2

Only df2 will be displayed, as shown below:

A simple strategy is to use Ipythonmodules.

from IPython.display import display

display(df1)
display(df2)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template