I am trying to find the max value under column "Climate change (kg CO2 eq.)" which is 1 but when I use scaled_df["Climate change (kg CO2 eq.)"].max()
I get the answer to be 0.9999999999999999
. How can I get the exact number?
Note: My dataset is very big, I've only provided a portion of it.
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
CodePudding user response:
How can I get the exact number?
That is the exact number, it is completely accurate.
Suppose you had three observations of one-tenth. You apparently performed a computation like this:
scale_factor = (.1 .1 .1) / .3
with the expectation that it would result in 1.0.
But the FP quantity .1
, with 24 bits of significand,
is quite different from the rational number 1 divided by 10.
It is impossible to represent the repeating digits
(repeating bits, similar to repeating decimals)
in a finite mantissa, so IEEE-754 computations are
not going to give the result you hoped for.
Let's try it in python:
>>> (.1 .1 .1) / .3
1.0000000000000002
>>>
Is that result "wrong"? No. The machine correctly computed exactly what we asked for.
It sounds like you have a requirement for calling .round( ... )
on the results you compute.