I'm having trouble working out how to round some data up to every 0.02. Here's my code:
def cpt_rnd(x):
return np.floor(x*50)/50
x = np.array([32.16, 32.18, 32.2, 32.22])
d = cpt_rnd(x)
print(d)
Which returns:
[32.14, 32.18, 32.2, 32.22]
And is missing the 32.16 - it has been rounded down to 32.14
I'm noticing similar behaviour in both ceil and floor not returning the correct answer. Here's the output using np.ceil
instead
[32.16, 32.18, 32.22, 32.22]
In this example there should be a 32.2 then 32.22, instead 32.22 is repeated. Any help would be appreciated!