2016-07-06 80 views
0

如果PandasSeries的索引屬於亞洲語言之一且長度可變,則打印輸出將不會正確對齊。在索引中使用亞洲文字顯示熊貓系列

import pandas as pd 
from IPython.display import display 

df = pd.Series(range(2), index = [ 'ミートボールスパゲッティ', 'ご飯' ]) 
display(df) 
print(df) 
df 

Output

注意,這僅與Series發生,與DataFramedisplay可以很好地顯示內容。

如何修復輸出?

回答

2

Series轉換爲DataFrame進行顯示。 CurrentlySeries沒有to_html()方法。因此,它們不能直接以這種格式顯示。

import pandas as pd 
from IPython.display import display 

df = pd.Series(range(2), index = [ 'ミートボールスパゲッティ', 'ご飯' ]) 
df.to_frame() 

enter image description here