Applying different formats to different columns dataframe

前端 未结 2 333
梦谈多话
梦谈多话 2021-01-15 16:01

I have the following df:

table:

     A             B               C                 D
0  0.000000       0.000000      -0.002520          -0.002520
1  0.20         


        
2条回答
  •  无人共我
    2021-01-15 16:07

    You can use applymap and assign output back:

    table[['A','D']]= table[['A','D']].applymap(format_AD)
    table[['B','C']]=  table[['B','C']].applymap(format_BC)
    print (table)
            A        B        C       D
    0   0.00%   0.000%  -0.003%  -0.00%
    1   0.21%   0.016%   0.003%   0.02%
    2  -0.01%  -0.000%   0.000%   0.00%
    

提交回复
热议问题