- numpy.count()
复制代码
1
2
3
4
5
6
7
8import 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
2
3[1 0 1] [0 1 0]
- numpy.rfind()
复制代码
1
2
3
4
5
6
7
8
9import 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'))
复制代码
1
2
3
4
5[ 0 -1 0] [-1 0 -1]
- numpy.isnumeric()
复制代码
1
2
3
4
5
6
7
8
9# 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'))
复制代码
1
2
3
4False False True
最后
以上就是能干棒棒糖最近收集整理的关于python-numpy最全攻略八-count, rfind, isnumeric的全部内容,更多相关python-numpy最全攻略八-count,内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复