numpy.mintypecode() function – Python
Last Updated :
18 Jun, 2020
Improve
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 :
# Python program explaining
# numpy.mintypecode() function
# importing numpy as geek
import numpy as geek
gfg = geek.mintypecode(['d', 'f', 'S'])
print (gfg)
dCode #2 :
# Python program explaining
# numpy.mintypecode() function
# importing numpy as geek
import numpy as geek
x = geek.array([1.1, 2-1.j])
gfg = geek.mintypecode(x)
print (gfg)
D