'''
表格显示控制
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}"})