Numpy fix()

This function is used to round the array values to the nearest integers towards zero.

Syntax

snippet
numpy.fix(array,b = None)

Parameters

  1. array: Array elements which are to be rounded.
  2. b: it is an Ndarray which is optional.

Return

An array containing the rounded values is returned.

Example

snippet
import numpy as np

arr = [0.23, 0.09, 1.2, 1.24, 9.99]

print("Input array:",arr)

r_arr = np.fix(arr)

print("Output array:",r_arr)

Output:

Output
Input array: [0.23, 0.09, 1.2, 1.24, 9.99] Output array: [0. 0. 1. 1. 9.]
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +