我是靠谱客的博主 能干棒棒糖,这篇文章主要介绍python-numpy最全攻略八-count, rfind, isnumeric,现在分享给大家,希望可以做个参考。

  1. numpy.count()
复制代码
1
2
3
4
5
6
7
8
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
2
3
[1 0 1] [0 1 0]
  1. numpy.rfind()
复制代码
1
2
3
4
5
6
7
8
9
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'))
复制代码
1
2
3
4
5
[ 0 -1 0] [-1 0 -1]
  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
4
False False True

最后

以上就是能干棒棒糖最近收集整理的关于python-numpy最全攻略八-count, rfind, isnumeric的全部内容,更多相关python-numpy最全攻略八-count,内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(97)

评论列表共有 0 条评论

立即
投稿
返回
顶部