numpy.mintypecode() function – Python
Last Updated :
18 Jun, 2020
numpy.mintypecode()
function return the character for the minimum-size type to which given types can be safely cast.
Syntax : numpy.mintypecode(typechars, typeset = ‘GDFgdf’, default = ‘d’)
Parameters :
typechars : [list of str or array_like] If a list of strings, each string should represent a dtype. If array_like, the character representation of the array dtype is used.
typeset : [str or list of str, optional] The set of characters that the returned character is chosen from. The default set is ‘GDFgdf’.
default : [str, optional] The default character, this is returned if none of the characters in typechars matches a character in typeset.
Return : [str] The character representing the minimum-size type that was found.
Code #1 :
import numpy as geek
gfg = geek.mintypecode([ 'd' , 'f' , 'S' ])
print (gfg)
|
Output :
d
Code #2 :
import numpy as geek
x = geek.array([ 1.1 , 2 - 1.j ])
gfg = geek.mintypecode(x)
print (gfg)
|
Output :
D
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...