检查剧情是否命中数字?

时间:2019-05-26 05:30:48

标签: python matplotlib anaconda

如何检查给定的数字,图中有多少次水平命中该数字并获得更高的数字?

我已经尝试过:

  import os
import numpy as np
import pylab as plt
import pandas as pd
df = pd.read_csv('C:/Users/Payam/Desktop/tesla-stock-price.csv')
df['avg'] = df[['high', 'low']].mean(axis=1)
e=df['avg'].values
x = df['date'].values
y = df['close'].values
z = df['open'].values

f, ax = plt.subplots(figsize=(20,10))
ax.plot(x,y,'b')
ax.set_xticks(x[::150]);
plt.xticks(rotation=90)
ax.plot(np.arange(len(x)),np.zeros(len(x))+50,'k.')

1 个答案:

答案 0 :(得分:0)

给出一些测试数组

test_array=np.array([1,6,8,65,4,2,5,8,9,6,4,6,9,0,8,6,4,32,])

您可以获取值大于一个数字(例如5)的所有索引,就像这样

print (np.where(test_array>5))
print (test_array[np.where(test_array>5)])