Python數據分析實戰【第三章】3.14-Matplotlib表格顯示控制【python】

1.按照百分數顯示

df = pd.DataFrame(np.random.randn(10,4),columns=['a','b','c','d'])
print(df.head())
df.head().style.format("{:.2%}")

在這裏插入圖片描述

2.顯示小數點數

df.head().style.format("{:.4f}")

在這裏插入圖片描述

3.顯示正負數

df.head().style.format("{:+.2f}")

在這裏插入圖片描述

4.分列顯示


df.head().style.format({'b':"{:.2%}", 'c':"{:+.3f}", 'd':"{:.3f}"})

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章