【python数据分析】matlabplot之表格显示控制

    xiaoxiao2022-07-13  146

    1、按照百分比显示

    import numpy as np import pandas as pd import matplotlib.pyplot as plt df = pd.DataFrame(np.random.randn(10,4),columns=['one','two','three','four']) 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({'one':"{:.2%}", 'two':"{:+.3f}", 'four':"{:.3f}"})

        

    最新回复(0)