Python Forum
Get numpy ceil and floor value for nearest two decimals
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get numpy ceil and floor value for nearest two decimals
#1
I'm trying to get ceiling value of the input for two decimals.


import numpy as np
a = np.array([-1.784, -1.5888, -0.24444, 0.25555, 1.5, 1.75, 2.0])

np.around(a,2)
array([-1.78, -1.59, -0.24, 0.26, 1.5 , 1.75, 2. ])

np.ceil(a)
array([-1., -1., -0., 1., 2., 2., 2.])

np.floor(a)
array([-2., -2., -1., 0., 1., 1., 2.])

Is there a way I can use Numpy ceil and floor methods to get such values to nearest second decimal?
Reply


Messages In This Thread
Get numpy ceil and floor value for nearest two decimals - by klllmmm - Jun-02-2023, 05:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python won 't do decimals SomebodySmart 5 783 Jun-08-2023, 07:14 PM
Last Post: buran
  compare and find the nearest element ? mr_gentle_sausage 4 1,103 Jan-15-2023, 07:11 AM
Last Post: DPaul
  Floor approximation problem in algorithm gradlon93 3 990 Dec-14-2022, 07:48 PM
Last Post: Gribouillis
  Adding Decimals to classes with OOP + rounding to significant digits (ATM demo) Drone4four 7 2,387 May-04-2022, 06:15 AM
Last Post: Drone4four
  Floor division problem with plotting x-axis tick labels Mark17 5 2,156 Apr-03-2022, 01:48 PM
Last Post: Mark17
  floats 2 decimals rwahdan 3 1,668 Dec-19-2021, 10:30 PM
Last Post: snippsat
  Converting decimals stylingpat 3 2,167 Mar-27-2021, 02:32 PM
Last Post: deanhystad
Photo Locate Noise floor level for a spectral data in Python Ranjan_Pal 1 3,094 Dec-19-2020, 10:04 AM
Last Post: Larz60+
  Floor division return value Chirumer 8 3,850 Nov-26-2020, 02:34 PM
Last Post: DeaD_EyE
  Rounding to the nearest eight wallgraffiti 2 2,120 Jul-15-2020, 06:05 PM
Last Post: wallgraffiti

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020