# numpy.sign() in Python

## numpy.sign() in Python

numpy.sign(array [, out]) function is used to indicate the sign of a number element-wise.
For integer inputs, if array value is greater than 0 it returns 1, if array value is less than 0 it returns -1, and if array value 0 it returns 0.

Syntax: numpy.sign()

Parameters :
array : [array_like] Input values.
out : [ndarray, optional] Output array placed with result.

Return : [ndarray] Returns the sign of array. If an array is scalar then the sign of array will be scalar.

Code 1 :

 `# Python Program illustrating` `# numpy.sign() method` ` ` `# importing numpy` `import` `numpy as geek  ` ` ` `# input arrays    ` `array1 ``=` `[``1``, ``0``, ``-``13``]` `array2 ``=`  `[``-``1``, ``0``, ``15``]` ` ` `# print the input arrays  ` `print` `(``"input array1 : "``, array1)` `print` `(``"input array2 : "``, array2)` ` ` `# determine the sign of integer numbers in an array  ` `print` `(``"\nCheck sign of array1 : "``, geek.sign(array1))` `print` `(``"\nCheck sign of array2 : "``, geek.sign(array2)) `

Output :

```array1 :  [1, 0, -13]
array2 :  [-1, 0, 15]

Check sign of array1 :  [ 1  0 -1]

Check sign of array2 :  [-1  0  1]

```

Code 2 :

 `# Python Program illustrating` `# numpy.sign() method` ` ` `# importing numpy  ` `import` `numpy as geek ` ` ` `# determine the sign of complex number` `print` `(``"\n Check sign of complex input1 : "``, geek.sign(``7``-``3j``))` `print` `(``"\n Check sign of complex input2 : "``, geek.sign(``-``7` `+` `3j``)) `

Output :

``` Check sign of complex input1 :  (1+0j)

Check sign of complex input2 :  (-1+0j)```

Last Updated on March 1, 2022 by admin

## Get minimum values in rows or columns with their index position in Pandas-DataframeGet minimum values in rows or columns with their index position in Pandas-Dataframe

Get minimum values in rows or columns with their index position in Pandas-Dataframe Let’s discuss

## Sort the words in lexicographical order in PythonSort the words in lexicographical order in Python

Sort the words in lexicographical order in Python Given a strings, we need to sort

## numpy.argsort() in Pythonnumpy.argsort() in Python

numpy.argsort() in Python numpy.argsort() function is used to perform an indirect sort along the given axis

Python | Pandas Dataframe/Series.head() method Python is a great language for doing data analysis, primarily

## close() and quit() method in Selenium Pythonclose() and quit() method in Selenium Python

How to use close() and quit() method in Selenium Python ? While doing stuff with

## Python program to find Cumulative sum of a listPython program to find Cumulative sum of a list

Python program to find Cumulative sum of a list The problem statement asks to produce

## send_keys() element method – Selenium Pythonsend_keys() element method – Selenium Python

send_keys() element method – Selenium Python Selenium’s Python Module is built to perform automated testing

## What is a clean, Pythonic way to have multiple constructors in Python?What is a clean, Pythonic way to have multiple constructors in Python?

What is a clean, Pythonic way to have multiple constructors in Python? Python does not