我试图在“气候变化(kg CO2 eq.)”栏下找到最大值。这是1,但是当我使用scaled_df["Climate change (kg CO2 eq.)"].max()时,我得到的答案是0.9999999999999999。我怎么才能得到确切的数字?
注意:我的数据集非常大,我只提供了其中的一部分。
Part's Orientation (Support's volume) (cm^3) Climate change (kg CO2 eq.) Climate change, incl biogenic carbon (kg CO2 eq.) Fine Particulate Matter Formation (kg PM2.5 eq.) Fossil depletion (kg oil eq.) Freshwater Consumption (m^3) Freshwater ecotoxicity (kg 1,4-DB eq.) Freshwater Eutrophication (kg P eq.) Human toxicity, cancer (kg 1,4-DB eq.) Human toxicity, non-cancer (kg 1,4-DB eq.) Ionizing Radiation (Bq. C-60 eq. to air) Land use (Annual crop eq. yr) Marine ecotoxicity (kg 1,4-DB eq.) Marine Eutrophication (kg N eq.) Metal depletion (kg Cu eq.) Photochemical Ozone Formation, Ecosystem (kg NOx eq.) Photochemical Ozone Formation, Human Health (kg NOx eq.) Stratospheric Ozone Depletion (kg CFC-11 eq.) Terrestrial Acidification (kg SO2 eq.) Terrestrial ecotoxicity (kg 1,4-DB eq.)
0 0.210866 0.040430 1.0 0.0 0.00 0.666667 0.040088 0.063802 0.040013 0.083205 0.005648 0.113808 0.104798 0.086400 0.108284 0.007368 0.091120 0.108676 0.090401 0.087426 0.101706 0.079028 0.080495 0.078380 0.082404 0.029502
1 0.210866 0.040430 1.0 0.2 0.00 0.666667 0.036597 0.038086 0.016068 0.074884 0.002636 0.045640 0.102285 0.082884 0.043371 0.003107 0.086700 0.105749 0.087161 0.084130 0.048885 0.072878 0.073529 0.074829 0.075438 0.011870
2 0.210866 0.044796 1.0 0.4 0.00 0.666667 0.031013 0.030436 0.008507 0.073035 0.001883 0.023401 0.102914 0.082494 0.022264 0.001854 0.086279 0.105749 0.086937 0.084130 0.032152 0.071341 0.071981 0.074698 0.073447 0.006456
3 0.210866 0.044311 1.0 0.6 0.00 0.666667 0.031013 0.026693 0.004883 0.072111 0.001506 0.012936 0.102914 0.082103 0.012289 0.001103 0.086069 0.105423 0.086602 0.084130 0.023950 0.070572 0.071207 0.074435 0.072452 0.003748
4 0.210866 0.045281 1.0 1.0 0.00 0.666667 0.031711 0.023438 0.001260 0.071803 0.001883 0.002180 0.103542 0.082884 0.002024 0.000601 0.086490 0.106074 0.087049 0.084542 0.015748 0.070572 0.071207 0.074961 0.072452 0.001249发布于 2022-10-01 17:18:08
我怎么才能得到确切的数字?
这是确切的数字,它是完全准确的。
假设你有三个十分之一的观测结果。很明显,你做了这样的计算:
scale_factor = (.1 + .1 + .1) / .3预期它会产生1.0。
但是,具有53位意义的FP quantity .1与有理数1除以10是完全不同的。在有限尾数中不可能表示重复数字(重复位,类似于重复小数),所以IEEE-754的计算不会给出你希望的结果。
让我们在python中试试:
>>> (.1 + .1 + .1) / .3
1.0000000000000002
>>> 这样的结果“错”吗?不是的。这台机器准确地计算了我们要的东西。
听起来,您需要对计算的结果调用.round( ... )。
https://stackoverflow.com/questions/73920088
复制相似问题