概述
- numpy.count()
import numpy as np
a=np.array(['geeks', 'for', 'geeks'])
# counting a substring
print(np.char.count(a,'geek'))
# This function returns the number of occurrences of a substring in the given string
# counting a substring
print(np.char.count(a, 'fo'))
[1 0 1]
[0 1 0]
- numpy.rfind()
import numpy as np
# This function returns the highest index of the substring if found in given string.
# If not found then it returns -1
a=np.array(['geeks', 'for', 'geeks'])
# counting a substring
print(np.char.rfind(a,'geek'))
# counting a substring
print(np.char.rfind(a, 'fo'))
[ 0 -1
0]
[-1
0 -1]
- numpy.isnumeric()
# This function returns “True” if all characters in the string are numeric characters,
# Otherwise, It returns “False”.
import numpy as np
# counting a substring
print(np.char.isnumeric('geeks'))
# counting a substring
print(np.char.isnumeric('12geeks'))
print(np.char.isnumeric('12'))
False
False
True
最后
以上就是能干棒棒糖为你收集整理的python-numpy最全攻略八-count, rfind, isnumeric的全部内容,希望文章能够帮你解决python-numpy最全攻略八-count, rfind, isnumeric所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复