0

I am trying to round numbers using NumPy, I have the following three numbers

0.01234
0.001234
0.0001234

and I want to round to 3 digits in order to get

0.0123
0.00123
0.000123

As you can see I round three digits after the last zero, that is the target, but with np.around I get the following results

0.012
0.001
0.

How can I do this?

Marcello Zago
  • 629
  • 5
  • 19
Tlaloc-ES
  • 4,825
  • 7
  • 38
  • 84
  • 1
    You are describing rounding to 3 significant figures (as opposed to 3 decimal places). There is no built-in way to do this: https://stackoverflow.com/questions/3410976/how-to-round-a-number-to-significant-figures-in-python – butterflyknife Dec 06 '22 at 10:12

0 Answers0