【问题标题】:Finding the indexes of a string array in Numpy Python在 Numpy Python 中查找字符串数组的索引
【发布时间】:2021-05-06 16:23:08
【问题描述】:

什么是 numpy 函数,它遍历数组 a,然后输出分配数组 b 的值的索引。

代码:

a = np.array(["BTCUSD", "ETHUSDC", "BBB", "ETHUSD", "cow"])
b=  np.array(["BTCUSD", "ETHUSD"])

预期输出:

Indexes: 0, 3

【问题讨论】:

  • `a=='hello' 有什么作用?

标签: python arrays numpy indexing format


【解决方案1】:
phraseIndex = np.where(a == phrase)

w3 Schools

Stack Overflow

NumPy Docs

【讨论】:

    猜你喜欢
    • 2016-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-17
    • 1970-01-01
    • 2021-04-16
    • 2013-12-25
    • 2018-11-20
    相关资源
    最近更新 更多