能否在 Jupyter 笔记本中提高 pandas.DataFrame.loc 函数的表格输出的精度?
我希望看到下表中 $f'_{cds}$ 的输出以 16 位十进制数字精度编写:
pd.set_option('precision', 16)
为熊猫设置输出精度,但我希望能够仅为 $f'_{cds}$ 列设置精度。
这是我正在使用的示例数据集:
h,$f' {ex}$,$f' {fwd}$,$E_{fwd}$,$E_{fwdn}$,$f' {cds}$,$E{CDS},$ {E_ CDSN} $ 0.5 -0.2955202066613395,-0.5172595595568812,0.2217393528955416,0.750335672137813,-0.2833598684940762,0.01216033816726331,0.04114892279159381 0.25,-0.2955202066613395,-0.4112478682644012,0.1157276616030616,0.3916065940481806,-0.2924514766709212,0.003068729990418351,0.01038416298190755 0.125, - 0.2955202066613395,-0.3543820493725782,0.05886184271123868,0.1991804329600149,-0.294751223803599,0.0007689828577405744,0.002602132918179141 0.0625,-0.2955202066613395,-0.325172396632464,0.02965218997112445,0.1003389592411367,-0.2953278482673038,0.0001923583940356965,0.0006509145219167214 0.03125,-0.2955202066613395,-0.3103980279268619,0.01487782126552234,0.05034451428416885,-0.2954721100178972,4.809664344235243e -05,0.0001627524695712948 0.015625,-0.2955202066613395,-0.3029715965360111,0.007451389874671585281048881048104042955081820601322,1.202460120736104e-05,4.068960746613514e-05 0.0078125,-0.2955202066613395,-0.2992489646633629,0.00372875800202338,0.01261760758815544,-0.2955172004835163,3.006177823283718e-06,1.017249499533797e-05 0.00390625,-0.2955202066613395,-0.297385344322862,0.001865137661522465,0.00631137099758419,-0.295519455115155, 7.515461845630789e-07,2.543129598661713e-06
对于示例数据集,Mohit 的答案如下:
sqrerr.loc[:, ("h","$E_{cds}$","$f'_{ex}$", "$f'_{cds}$")].style.format({"$f'_{cds}$" : '{:.16f}'})
白衣染霜花
神不在的星期二
相关分类