'''
表格顯示控制
df.style.format()
只是更改了顯示樣式
原數據不會更改
'''
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
df = pd.DataFrame(np.random.randn(10,4),columns=['a','b','c','d'])
sty = df.style
# 按照百分數顯示
df = pd.DataFrame(np.random.randn(10,4),columns=['a','b','c','d'])
print(df.head())
df.head().style.format("{:.2%}")
# 顯示小數點數
df.head().style.format("{:.4f}")
# 顯示正負數
df.head().style.format("{:+.2f}")
# 分列顯示
df.head().style.format({'b':"{:.2%}", 'c':"{:+.3f}", 'd':"{:.3f}"})