用pandas的sort_values对数据进行排序后输出,发现列名一直没法对齐,这是为什么?
闭关修行中......
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.
jupyter
print
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.
Ipython
from IPython.display import display display(df1) display(df2)
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
Only df2 will be displayed, as shown below:
A simple strategy is to use
Ipython
modules.